share.vue 7.3 KB

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