share.vue 7.3 KB

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