share.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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">
  39. <image class="image" :src="item.icon&&item.icon.length>0?item.icon[0].url:''"
  40. mode=""></image>
  41. </view>
  42. <view class="name">
  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. if (that.id) {
  116. uni.navigateTo({
  117. url: `/pagesHome/order/order?key=${arr.data.key}&group_id=${that.id}`
  118. })
  119. } else {
  120. uni.navigateTo({
  121. url: `/pagesHome/order/order?key=${arr.data.key}`
  122. })
  123. }
  124. } else {
  125. uni.showToast({
  126. title: arr.data.msg,
  127. icon: 'none'
  128. })
  129. }
  130. } else {
  131. uni.showToast({
  132. title: arr.errmsg,
  133. icon: 'none'
  134. })
  135. }
  136. } else {
  137. uni.navigateTo({
  138. url: `/pages/login/index`
  139. })
  140. }
  141. },
  142. watchLogin() {
  143. const that = this;
  144. uni.getStorage({
  145. key: 'token',
  146. success: function(res) {
  147. let user = that.$jwt(res.data);
  148. if (user) that.$set(that, `user`, user)
  149. }
  150. })
  151. },
  152. async search() {
  153. const that = this;
  154. if (that.id) {
  155. let res = await that.$api(`/group/${that.id}`, `GET`);
  156. if (res.errcode == '0') {
  157. if (res.data.status != '-1') {
  158. res.data.persons = res.data.persons.filter(i => i.status == '0')
  159. }
  160. that.$set(that, `info`, res.data);
  161. let share = {
  162. title: res.data.goods.name,
  163. path: `/pagesHome/group/share?id=${that.id}`,
  164. imageUrl: '',
  165. }
  166. that.$set(that, `share`, share);
  167. } else {
  168. uni.showToast({
  169. title: res.errmsg,
  170. icon: 'none'
  171. })
  172. }
  173. }
  174. },
  175. // 参团
  176. toOpen() {
  177. const that = this;
  178. that.$refs.popup.open();
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .main {
  185. display: flex;
  186. flex-direction: column;
  187. width: 100vw;
  188. height: 100vh;
  189. background-color: #23B67A;
  190. .one {
  191. background-color: #D9FDEF;
  192. margin: 2vw 6vw;
  193. border-radius: 10px;
  194. padding: 2vw;
  195. .one_1 {
  196. text-align: center;
  197. border-bottom: 1px dashed #085623;
  198. margin: 0 0 2vw 0;
  199. padding: 0 0 1vw 0;
  200. text {
  201. font-size: 61px;
  202. font-weight: bold;
  203. color: #357846;
  204. font-family: cursive;
  205. }
  206. }
  207. .one_2 {
  208. text-align: center;
  209. text {
  210. padding: 0 5px;
  211. }
  212. text:nth-child(2) {
  213. font-size: 18px;
  214. letter-spacing: 5px;
  215. font-weight: bold;
  216. color: #357846;
  217. }
  218. }
  219. }
  220. .two {
  221. background-color: #D9FDEF;
  222. margin: 2vw;
  223. border-radius: 10px;
  224. padding: 2vw;
  225. display: flex;
  226. .two_1 {
  227. display: flex;
  228. .img {
  229. .image {
  230. width: 100px;
  231. height: 100px;
  232. border-radius: 90px;
  233. }
  234. }
  235. }
  236. .two_2 {
  237. padding: 0 0 0 2vw;
  238. .name {
  239. font-size: 20px;
  240. font-weight: bold;
  241. margin: 0 0 2vw 0;
  242. color: #357846;
  243. }
  244. .money {
  245. font-size: 18px;
  246. color: #ff0000;
  247. font-weight: bold;
  248. margin: 0 0 2vw 0;
  249. }
  250. .brief {
  251. font-size: 14px;
  252. overflow: hidden;
  253. text-overflow: ellipsis;
  254. -webkit-line-clamp: 2;
  255. word-break: break-all;
  256. display: -webkit-box;
  257. -webkit-box-orient: vertical;
  258. color: #858585;
  259. }
  260. }
  261. }
  262. .thr {
  263. position: relative;
  264. flex-grow: 1;
  265. margin: 0 2vw 2vw 2vw;
  266. width: 94vw;
  267. border-radius: 10px;
  268. border: 3px solid #D9FDEF;
  269. .thr_1 {
  270. padding: 2vw;
  271. display: flex;
  272. flex-wrap: wrap;
  273. .list {
  274. width: 20vw;
  275. text-align: center;
  276. margin: 0 3vw 2vw 0;
  277. .img {
  278. .image {
  279. width: 16vw;
  280. height: 16vw;
  281. border-radius: 90px;
  282. }
  283. }
  284. .name {
  285. font-size: 14px;
  286. font-weight: bold;
  287. }
  288. }
  289. .list:nth-child(4n) {
  290. margin: 0 0 2vw 0;
  291. }
  292. .list_1 {
  293. button {
  294. padding: 0;
  295. border-radius: 90px;
  296. width: 16vw;
  297. height: 16vw;
  298. text-align: center;
  299. line-height: 16vw;
  300. background-color: #ffffff5f;
  301. font-size: 16px;
  302. font-weight: bold;
  303. color: #fff;
  304. }
  305. }
  306. }
  307. }
  308. }
  309. .scroll-view {
  310. position: absolute;
  311. top: 0;
  312. left: 0;
  313. right: 0;
  314. bottom: 0;
  315. .list-scroll-view {
  316. display: flex;
  317. flex-direction: column;
  318. }
  319. }
  320. .content {
  321. height: 60vw;
  322. .one {
  323. display: flex;
  324. justify-content: flex-start;
  325. align-items: center;
  326. margin: 0 2vw;
  327. padding: 2vw 0;
  328. text {
  329. margin: 0 2vw 0 0;
  330. }
  331. text:last-child {
  332. margin: 0 0 0 2vw;
  333. font-size: var(--font12Size);
  334. color: var(--f85Color);
  335. }
  336. }
  337. .btn {
  338. display: flex;
  339. justify-content: space-between;
  340. position: fixed;
  341. bottom: 0;
  342. .button {
  343. width: 100vw;
  344. padding: 4vw 0;
  345. background-color: var(--fFB1Color);
  346. text-align: center;
  347. font-size: var(--font18Szie);
  348. color: var(--mainColor);
  349. }
  350. }
  351. }
  352. </style>