index.vue 11 KB

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