share.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1">
  6. <text>超值拼团</text>
  7. </view>
  8. <view class="one_2">
  9. <text class="iconfont icon-qianggou"></text>
  10. <text>快叫上伙伴一起抢</text>
  11. <text class="iconfont icon-qianggou"></text>
  12. </view>
  13. </view>
  14. <view class="two">
  15. <view class="two_1">
  16. <view class="img">
  17. <image class="image" :src="info.goods.file&&info.goods.file.length>0?info.goods.file[0].url:''" mode=""></image>
  18. </view>
  19. </view>
  20. <view class="two_2">
  21. <view class="name">
  22. {{info.goods.name}}
  23. </view>
  24. <view class="money">
  25. ¥{{info.goodsSpec.group_config.money}}元
  26. </view>
  27. <view class="brief">
  28. {{info.goods.brief||''}}
  29. </view>
  30. </view>
  31. </view>
  32. <view class="thr">
  33. <scroll-view scroll-y="true" class="scroll-view">
  34. <view class="list-scroll-view">
  35. <view class="thr_1">
  36. <view class="list" v-for="(item,index) in info.persons" :key="index">
  37. <view class="img">
  38. <image class="image" :src="item.icon&&item.icon.length>0?item.icon[0].url:''" mode=""></image>
  39. </view>
  40. <view class="name">
  41. {{item.name}}
  42. </view>
  43. </view>
  44. <view class="list list_1" v-if="info.person_limit>info.persons.length">
  45. <button type="default" size="mini" @tap.stop="toOpen">参团</button>
  46. </view>
  47. </view>
  48. </view>
  49. </scroll-view>
  50. </view>
  51. </view>
  52. <uni-popup ref="popup" background-color="#fff" type="bottom">
  53. <view class="content">
  54. <view class="one">
  55. <text>数量</text>
  56. <view class="count">
  57. <uni-number-box :min="1" :max="info.goodsSpec.num" v-model="num" @change="toCount">
  58. </uni-number-box>
  59. </view>
  60. <text>库存{{info.goodsSpec.num||0}}</text>
  61. </view>
  62. <view class="btn">
  63. <text @click="onSubmit" class="button">确认参团</text>
  64. </view>
  65. </view>
  66. </uni-popup>
  67. </mobile-frame>
  68. </template>
  69. <script>
  70. export default {
  71. data() {
  72. return {
  73. id: '',
  74. user: {},
  75. info: {},
  76. num: 1,
  77. };
  78. },
  79. onLoad: function(e) {
  80. const that = this;
  81. that.$set(that, `id`, e.id || '');
  82. },
  83. onShow: function() {
  84. const that = this;
  85. that.watchLogin();
  86. that.search();
  87. },
  88. methods: {
  89. // 计数器
  90. toCount(e) {
  91. const that = this;
  92. that.num = e;
  93. },
  94. // 确认开团 立即参团
  95. async onSubmit() {
  96. const that = this;
  97. let user = that.user;
  98. if (user._id) {
  99. let data = {
  100. customer: user._id,
  101. shop: that.info.shop,
  102. goods: that.info.goods._id,
  103. goodsSpec: that.info.goodsSpec._id,
  104. num: that.num,
  105. type: '1',
  106. group: that.id
  107. }
  108. let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
  109. if (arr.errcode == '0') {
  110. if (arr.data.result == true) {
  111. if (that.id) {
  112. uni.navigateTo({
  113. url: `/pagesHome/order/order?key=${arr.data.key}&group_id=${that.id}`
  114. })
  115. } else {
  116. uni.navigateTo({
  117. url: `/pagesHome/order/order?key=${arr.data.key}`
  118. })
  119. }
  120. } else {
  121. uni.showToast({
  122. title: arr.data.msg,
  123. icon: 'none'
  124. })
  125. }
  126. } else {
  127. uni.showToast({
  128. title: arr.errmsg,
  129. icon: 'none'
  130. })
  131. }
  132. } else {
  133. uni.navigateTo({
  134. url: `/pages/login/index`
  135. })
  136. }
  137. },
  138. watchLogin() {
  139. const that = this;
  140. uni.getStorage({
  141. key: 'token',
  142. success: function(res) {
  143. let user = that.$jwt(res.data);
  144. if (user) that.$set(that, `user`, user)
  145. }
  146. })
  147. },
  148. async search() {
  149. const that = this;
  150. if (that.id) {
  151. let res = await that.$api(`/group/${that.id}`, `GET`);
  152. if (res.errcode == '0') {
  153. if (res.data.status != '-1') {
  154. res.data.persons = res.data.persons.filter(i => i.status == '0')
  155. }
  156. that.$set(that, `info`, res.data);
  157. uni.getStorage({
  158. key: 'config',
  159. success: function(config) {
  160. // 赋值默认值
  161. that.$config.share = {
  162. title: res.data.goods.name,
  163. path: '/pagesHome/group/share?id=${that.id}',
  164. imageUrl: config.config.share[0].url
  165. }
  166. }
  167. });
  168. } else {
  169. uni.showToast({
  170. title: res.errmsg,
  171. icon: 'none'
  172. })
  173. }
  174. }
  175. },
  176. // 参团
  177. toOpen() {
  178. const that = this;
  179. that.$refs.popup.open();
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss">
  185. .main {
  186. display: flex;
  187. flex-direction: column;
  188. width: 100vw;
  189. height: 100vh;
  190. background-color: #23B67A;
  191. .one {
  192. background-color: #D9FDEF;
  193. margin: 2vw 6vw;
  194. border-radius: 10px;
  195. padding: 2vw;
  196. .one_1 {
  197. text-align: center;
  198. border-bottom: 1px dashed #085623;
  199. margin: 0 0 2vw 0;
  200. padding: 0 0 1vw 0;
  201. text {
  202. font-size: 61px;
  203. font-weight: bold;
  204. color: #357846;
  205. font-family: cursive;
  206. }
  207. }
  208. .one_2 {
  209. text-align: center;
  210. text {
  211. padding: 0 5px;
  212. }
  213. text:nth-child(2) {
  214. font-size: 18px;
  215. letter-spacing: 5px;
  216. font-weight: bold;
  217. color: #357846;
  218. }
  219. }
  220. }
  221. .two {
  222. background-color: #D9FDEF;
  223. margin: 2vw;
  224. border-radius: 10px;
  225. padding: 2vw;
  226. display: flex;
  227. .two_1 {
  228. display: flex;
  229. .img {
  230. .image {
  231. width: 100px;
  232. height: 100px;
  233. border-radius: 90px;
  234. }
  235. }
  236. }
  237. .two_2 {
  238. padding: 0 0 0 2vw;
  239. .name {
  240. font-size: 20px;
  241. font-weight: bold;
  242. margin: 0 0 2vw 0;
  243. color: #357846;
  244. }
  245. .money {
  246. font-size: 18px;
  247. color: #ff0000;
  248. font-weight: bold;
  249. margin: 0 0 2vw 0;
  250. }
  251. .brief {
  252. font-size: 14px;
  253. overflow: hidden;
  254. text-overflow: ellipsis;
  255. -webkit-line-clamp: 2;
  256. word-break: break-all;
  257. display: -webkit-box;
  258. -webkit-box-orient: vertical;
  259. color: #858585;
  260. }
  261. }
  262. }
  263. .thr {
  264. position: relative;
  265. flex-grow: 1;
  266. margin: 0 2vw 2vw 2vw;
  267. width: 94vw;
  268. border-radius: 10px;
  269. border: 3px solid #D9FDEF;
  270. .thr_1 {
  271. padding: 2vw;
  272. display: flex;
  273. flex-wrap: wrap;
  274. .list {
  275. width: 20vw;
  276. text-align: center;
  277. margin: 0 3vw 2vw 0;
  278. .img {
  279. .image {
  280. width: 16vw;
  281. height: 16vw;
  282. border-radius: 90px;
  283. }
  284. }
  285. .name {
  286. font-size: 14px;
  287. font-weight: bold;
  288. }
  289. }
  290. .list:nth-child(4n) {
  291. margin: 0 0 2vw 0;
  292. }
  293. .list_1 {
  294. button {
  295. padding: 0;
  296. border-radius: 90px;
  297. width: 16vw;
  298. height: 16vw;
  299. text-align: center;
  300. line-height: 16vw;
  301. background-color: #ffffff5f;
  302. font-size: 16px;
  303. font-weight: bold;
  304. color: #fff;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. .scroll-view {
  311. position: absolute;
  312. top: 0;
  313. left: 0;
  314. right: 0;
  315. bottom: 0;
  316. .list-scroll-view {
  317. display: flex;
  318. flex-direction: column;
  319. }
  320. }
  321. .content {
  322. height: 60vw;
  323. .one {
  324. display: flex;
  325. justify-content: flex-start;
  326. align-items: center;
  327. margin: 0 2vw;
  328. padding: 2vw 0;
  329. text {
  330. margin: 0 2vw 0 0;
  331. }
  332. text:last-child {
  333. margin: 0 0 0 2vw;
  334. font-size: var(--font12Size);
  335. color: var(--f85Color);
  336. }
  337. }
  338. .btn {
  339. display: flex;
  340. justify-content: space-between;
  341. position: fixed;
  342. bottom: 0;
  343. .button {
  344. width: 100vw;
  345. padding: 4vw 0;
  346. background-color: var(--fFB1Color);
  347. text-align: center;
  348. font-size: var(--font18Szie);
  349. color: var(--mainColor);
  350. }
  351. }
  352. }
  353. </style>