index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <!-- <view class="one_1">参团商品</view> -->
  6. <view class="list" @tap="toView">
  7. <image class="image" :src="goodsInfo.file&&goodsInfo.file.length>0?goodsInfo.file[0].url:''"
  8. mode="">
  9. </image>
  10. <view class="list_1_1">
  11. <view class="name">
  12. {{goodsInfo.name||'暂无'}}
  13. </view>
  14. <view class="money">
  15. <text>¥</text>
  16. <text>{{specsInfo.sell_money}}</text>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="two">
  22. <button type="default" size="default" @click="toGroup()">我要开团</button>
  23. </view>
  24. <view class="thr">
  25. <!-- <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage">
  26. <view class="list-scroll-view"> -->
  27. <view class="list" v-for="(item, index) in list" :key="index">
  28. <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''" mode="">
  29. </image>
  30. <view class="list_1">
  31. <view class="name">
  32. {{item.name||'暂无'}}
  33. </view>
  34. <view class="some">
  35. <text>店铺名称</text>
  36. <text>{{item.name||'暂无'}}</text>
  37. </view>
  38. <view class="some">
  39. <text>规格名称</text>
  40. <text>{{item.name||'暂无'}}</text>
  41. </view>
  42. <view class="other">
  43. <view class="other_1">
  44. <text>¥</text>
  45. <text>{{item.sell_money||0}}</text>
  46. </view>
  47. <view class="other_2">
  48. <view class="btn" @click="toJoin(item)"><text>已参团{{item.num||'5'}}人</text>立即参团</view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- </view>
  54. </scroll-view> -->
  55. </view>
  56. </view>
  57. </mobile-frame>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. query: {},
  64. user: {},
  65. // 商品详情
  66. goodsInfo: {},
  67. // 规格详情
  68. specsInfo: {},
  69. // 店铺详情
  70. shopInfo: {},
  71. // 参团列表
  72. list: [{
  73. "_id": "633559dfa4e39d34f49990af",
  74. "name": "商品6",
  75. "view_num": 54,
  76. "sell_money": 1,
  77. "file": [{
  78. "id": "20221010102439",
  79. "name": "ece9214111e760727a166eaac037fdc0.jpg",
  80. "uri": "/files/point/goods/20221010102439.jpg",
  81. "url": "https://broadcast.waityou24.cn/files/point/goods/20221010102439.jpg",
  82. "uid": 1665368678937,
  83. "status": "success"
  84. }],
  85. "time": "2022-10-11 15:50:27"
  86. }, {
  87. "_id": "63437e3ba163596194c3e830",
  88. "name": "王大拿商品1",
  89. "view_num": 37,
  90. "sell_money": 15,
  91. "file": [{
  92. "id": "20221010100628",
  93. "name": "0e7edbb2f8e99780f253a3604adc32e4.jpg",
  94. "uri": "/files/point/goods/20221010100628.jpg",
  95. "url": "https://broadcast.waityou24.cn/files/point/goods/20221010100628.jpg",
  96. "uid": 1665367588108,
  97. "status": "success"
  98. }],
  99. "time": "2022-10-11 15:08:29"
  100. }, {
  101. "_id": "6343878989bdcb128d846990",
  102. "name": "王大拿商品2",
  103. "view_num": 196,
  104. "sell_money": 50,
  105. "file": [{
  106. "id": "20221011092711",
  107. "name": "25.png",
  108. "uri": "/files/point/goods/20221011092711.png",
  109. "url": "https://broadcast.waityou24.cn/files/point/goods/20221011092711.png",
  110. "uid": 1665451632365,
  111. "status": "success"
  112. }],
  113. "time": "2022-10-11 15:05:41"
  114. }, {
  115. "_id": "63353758101f3c01048c4f61",
  116. "name": "test",
  117. "view_num": 265,
  118. "sell_money": 0.1,
  119. "file": [{
  120. "id": "20220929141236",
  121. "name": "f0e22552dddcf494f9720c655a8420a.png",
  122. "uri": "/files/point/goods/20220929141236.png",
  123. "url": "https://broadcast.waityou24.cn/files/point/goods/20220929141236.png",
  124. "uid": 1664431956868,
  125. "status": "success"
  126. }],
  127. "time": "2022-10-11 11:21:01"
  128. }, {
  129. "_id": "633930162a24745ec0006373",
  130. "name": "测试店铺1-商品1",
  131. "view_num": 59,
  132. "sell_money": 0.1,
  133. "file": [{
  134. "id": "20220929141236",
  135. "name": "f0e22552dddcf494f9720c655a8420a.png",
  136. "uri": "/files/point/goods/20220929141236.png",
  137. "url": "https://broadcast.waityou24.cn/files/point/goods/20220929141236.png",
  138. "uid": 1664431956868,
  139. "status": "success"
  140. }],
  141. "time": "2022-10-11 11:15:36"
  142. }, {
  143. "_id": "63355854a4e39d34f499904a",
  144. "name": "商品2",
  145. "view_num": 164,
  146. "sell_money": 1,
  147. "file": [{
  148. "id": "20220929163309",
  149. "name": "f0e22552dddcf494f9720c655a8420a.png",
  150. "uri": "/files/point/goods/20220929163309.png",
  151. "url": "https://broadcast.waityou24.cn/files/point/goods/20220929163309.png",
  152. "uid": 1664440389135,
  153. "status": "success"
  154. }],
  155. "time": "2022-10-11 11:13:11"
  156. }],
  157. total: 0,
  158. skip: 0,
  159. limit: 6,
  160. page: 0
  161. };
  162. },
  163. onLoad: async function(e) {
  164. const that = this;
  165. that.$set(that, `query`, {
  166. goods_id: e.goods_id || '6343878989bdcb128d846990',
  167. specs_id: e.specs_id || '634394bc32c3065a80eb14ad'
  168. });
  169. },
  170. onShow: function() {
  171. const that = this;
  172. that.watchLogin();
  173. that.search();
  174. },
  175. methods: {
  176. // 开团
  177. async toGroup() {
  178. const that = this;
  179. let user = that.user;
  180. if (user) {
  181. let data = {
  182. shop: that.shopInfo._id,
  183. goods: that.goodsInfo._id,
  184. goodsSpec: that.specsInfo._id,
  185. leader: user._id
  186. }
  187. const arr = await that.$api(`/group`, 'POST', data)
  188. if (arr.errcode == '0') {
  189. uni.showToast({
  190. title: '开团成功',
  191. icon: 'none'
  192. })
  193. that.clearPage();
  194. that.search()
  195. } else {
  196. uni.showToast({
  197. title: arr.data.errmsg || '下单失败!',
  198. icon: 'none'
  199. })
  200. }
  201. } else {
  202. uni.showToast({
  203. title: '无用户登录无法开团',
  204. icon: 'none'
  205. })
  206. }
  207. },
  208. // 立即参团
  209. toJoin(e) {
  210. console.log(e);
  211. },
  212. // 监听用户是否登录
  213. watchLogin() {
  214. const that = this;
  215. uni.getStorage({
  216. key: 'token',
  217. success: function(res) {
  218. let user = that.$jwt(res.data);
  219. that.$set(that, `user`, user);
  220. },
  221. fail: function(err) {}
  222. })
  223. },
  224. // 查询列表
  225. async search() {
  226. const that = this;
  227. let res;
  228. res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
  229. id: that.query.goods_id
  230. });
  231. if (res.errcode == '0') {
  232. that.$set(that, `goodsInfo`, res.data.goods)
  233. that.$set(that, `shopInfo`, res.data.shop)
  234. }
  235. res = await that.$api(`/goodsSpec/${that.query.specs_id}`, 'GET')
  236. if (res.errcode == '0') {
  237. that.$set(that, `specsInfo`, res.data);
  238. }
  239. let info = {
  240. skip: that.skip,
  241. limit: that.limit,
  242. }
  243. res = await that.$api(`/group`, 'GET', {
  244. ...info
  245. })
  246. if (res.errcode == '0') {
  247. let list = [...that.list, ...res.data];
  248. that.$set(that, `list`, list);
  249. that.$set(that, `total`, res.total)
  250. }
  251. },
  252. // 分页
  253. toPage(e) {
  254. const that = this;
  255. let list = that.list;
  256. let limit = that.limit;
  257. if (that.total > list.length) {
  258. uni.showLoading({
  259. title: '加载中',
  260. mask: true
  261. })
  262. let page = that.page + 1;
  263. that.$set(that, `page`, page)
  264. let skip = page * limit;
  265. that.$set(that, `skip`, skip)
  266. that.search();
  267. uni.hideLoading();
  268. } else uni.showToast({
  269. title: '没有更多数据了'
  270. });
  271. },
  272. // 清空列表
  273. clearPage() {
  274. const that = this;
  275. that.$set(that, `list`, [])
  276. that.$set(that, `skip`, 0)
  277. that.$set(that, `limit`, 6)
  278. that.$set(that, `page`, 0)
  279. }
  280. }
  281. }
  282. </script>
  283. <style lang="scss">
  284. .main {
  285. display: flex;
  286. flex-direction: column;
  287. width: 100vw;
  288. height: 100vh;
  289. .one {
  290. .one_1 {
  291. text-align: center;
  292. font-size: var(--font16Size);
  293. font-weight: bold;
  294. margin: 2vw 0;
  295. }
  296. .list {
  297. display: flex;
  298. flex-direction: row;
  299. justify-content: space-between;
  300. width: 91vw;
  301. border: 0.5vw dashed var(--ff0Color);
  302. margin: 2vw 2vw 0 2vw;
  303. padding: 2vw;
  304. border-radius: 5px;
  305. .image {
  306. width: 25vw;
  307. height: 25vw;
  308. border-radius: 5px;
  309. margin: 0 2vw 0 0;
  310. }
  311. .list_1_1 {
  312. display: flex;
  313. flex-direction: column;
  314. justify-content: space-between;
  315. flex-grow: 1;
  316. padding: 2vw 0;
  317. .name {
  318. font-size: var(--font16Size);
  319. margin: 0 0 1vw 0;
  320. }
  321. .money {
  322. color: var(--fFB1Color);
  323. font-size: var(--font14Size);
  324. margin: 0 0 1vw 0;
  325. text:last-child {
  326. font-size: var(--font16Size);
  327. }
  328. }
  329. }
  330. }
  331. }
  332. .two {
  333. margin: 4vw 0;
  334. text-align: center;
  335. button {
  336. margin: 0 2vw 2vw 2vw;
  337. background-color: #FFA500;
  338. color: var(--fffColor);
  339. }
  340. }
  341. .thr {
  342. position: relative;
  343. flex-grow: 1;
  344. .list {
  345. display: flex;
  346. flex-direction: row;
  347. justify-content: space-between;
  348. align-items: center;
  349. width: 91vw;
  350. border: 1px solid var(--f1Color);
  351. margin: 2vw 2vw 0 2vw;
  352. padding: 0 2vw;
  353. border-radius: 5px;
  354. .image {
  355. width: 25vw;
  356. height: 25vw;
  357. border-radius: 5px;
  358. margin: 0 2vw 0 0;
  359. }
  360. .list_1 {
  361. display: flex;
  362. flex-direction: column;
  363. flex-grow: 1;
  364. padding: 2vw 0;
  365. .name {
  366. font-size: var(--font16Size);
  367. margin: 0 0 1vw 0;
  368. }
  369. .some {
  370. color: var(--f85Color);
  371. font-size: var(--font14Size);
  372. margin: 0 0 1vw 0;
  373. text:last-child {
  374. margin: 0 0 0 1vw;
  375. color: var(--f00Color);
  376. }
  377. }
  378. .other {
  379. display: flex;
  380. justify-content: space-between;
  381. align-items: center;
  382. .other_1 {
  383. font-size: var(--font14Size);
  384. color: var(--f85Color);
  385. text {
  386. font-weight: bold;
  387. padding: 0 1vw 0 0;
  388. color: var(--ff0Color);
  389. }
  390. }
  391. .other_2 {
  392. .btn {
  393. display: flex;
  394. flex-direction: column;
  395. align-items: center;
  396. margin: 0 2vw;
  397. padding: 2vw 3vw;
  398. background-color: var(--ff0Color);
  399. color: var(--fffColor);
  400. border-radius: 2vw;
  401. font-size: var(--font14Size);
  402. text {
  403. font-size: var(--font12Size);
  404. }
  405. }
  406. }
  407. }
  408. }
  409. }
  410. }
  411. }
  412. .scroll-view {
  413. position: absolute;
  414. top: 0;
  415. left: 0;
  416. right: 0;
  417. bottom: 0;
  418. .list-scroll-view {
  419. display: flex;
  420. flex-direction: column;
  421. }
  422. }
  423. </style>