share.vue 7.9 KB

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