index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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.person_limit||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. <uni-popup ref="popup" background-color="#fff" type="bottom">
  63. <view class="content">
  64. <view class="one">
  65. <text>数量</text>
  66. <view class="count">
  67. <uni-number-box :min="1" :max="specsInfo.num" v-model="num" @change="toCount">
  68. </uni-number-box>
  69. </view>
  70. <text>库存{{specsInfo.num||0}}</text>
  71. </view>
  72. <view class="btn">
  73. <text @click="onSubmit" class="button">确认开团</text>
  74. </view>
  75. </view>
  76. </uni-popup>
  77. </mobile-frame>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. query: {},
  84. user: {},
  85. // 商品详情
  86. goodsInfo: {},
  87. // 规格详情
  88. specsInfo: {},
  89. // 店铺详情
  90. shopInfo: {},
  91. // 参团列表
  92. list: [],
  93. num: 0,
  94. total: 0,
  95. skip: 0,
  96. limit: 6,
  97. page: 0
  98. };
  99. },
  100. onLoad: async function(e) {
  101. const that = this;
  102. that.$set(that, `query`, {
  103. goods_id: e.goods_id || '6343878989bdcb128d846990',
  104. specs_id: e.specs_id || '634394bc32c3065a80eb14ad'
  105. });
  106. },
  107. onShow: function() {
  108. const that = this;
  109. that.watchLogin();
  110. that.search();
  111. },
  112. methods: {
  113. // 开团
  114. async toGroup() {
  115. const that = this;
  116. that.$refs.popup.open();
  117. // let user = that.user;
  118. // if (user._id) {
  119. // let data = {
  120. // customer: user._id,
  121. // shop: that.shopInfo._id,
  122. // goods: that.goodsInfo._id,
  123. // goodsSpec: that.specsInfo._id,
  124. // num: that.num,
  125. // }
  126. // let arr = await that.$api(`/util/checkCanBuy`, 'POST', data)
  127. // if (arr.errcode == '0') {
  128. // if (arr.data.result == true) {
  129. // uni.navigateTo({
  130. // url: `/pagesHome/order/order?key=${arr.data.key}`
  131. // })
  132. // } else {
  133. // uni.showToast({
  134. // title: arr.data.msg,
  135. // icon: 'none'
  136. // })
  137. // }
  138. // } else {
  139. // uni.showToast({
  140. // title: arr.errmsg,
  141. // icon: 'none'
  142. // })
  143. // }
  144. // const arr = await that.$api(`/group`, 'POST', data)
  145. // if (arr.errcode == '0') {
  146. // uni.showToast({
  147. // title: '开团成功',
  148. // icon: 'none'
  149. // })
  150. // that.clearPage();
  151. // that.search()
  152. // } else {
  153. // uni.showToast({
  154. // title: arr.data.errmsg,
  155. // icon: 'none'
  156. // })
  157. // }
  158. // } else {
  159. // uni.navigateTo({
  160. // url: `/pages/login/index`
  161. // })
  162. // }
  163. },
  164. // 计数器
  165. toCount(e) {
  166. const that = this;
  167. that.num = e;
  168. },
  169. // 立即参团
  170. toJoin(e) {
  171. const that = this;
  172. let user = that.user;
  173. if (user._id) {
  174. console.log(e);
  175. } else {
  176. uni.navigateTo({
  177. url: `/pages/login/index`
  178. })
  179. }
  180. },
  181. // 监听用户是否登录
  182. watchLogin() {
  183. const that = this;
  184. uni.getStorage({
  185. key: 'token',
  186. success: function(res) {
  187. let user = that.$jwt(res.data);
  188. that.$set(that, `user`, user);
  189. },
  190. fail: function(err) {}
  191. })
  192. },
  193. // 查询列表
  194. async search() {
  195. const that = this;
  196. let res;
  197. res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
  198. id: that.query.goods_id
  199. });
  200. if (res.errcode == '0') {
  201. that.$set(that, `goodsInfo`, res.data.goods)
  202. that.$set(that, `shopInfo`, res.data.shop)
  203. }
  204. res = await that.$api(`/goodsSpec/${that.query.specs_id}`, 'GET')
  205. if (res.errcode == '0') {
  206. that.$set(that, `specsInfo`, res.data);
  207. }
  208. let info = {
  209. skip: that.skip,
  210. limit: that.limit,
  211. }
  212. res = await that.$api(`/group`, 'GET', {
  213. ...info
  214. })
  215. if (res.errcode == '0') {
  216. let list = [...that.list, ...res.data];
  217. that.$set(that, `list`, list);
  218. that.$set(that, `total`, res.total)
  219. }
  220. },
  221. // 分页
  222. toPage(e) {
  223. const that = this;
  224. let list = that.list;
  225. let limit = that.limit;
  226. if (that.total > list.length) {
  227. uni.showLoading({
  228. title: '加载中',
  229. mask: true
  230. })
  231. let page = that.page + 1;
  232. that.$set(that, `page`, page)
  233. let skip = page * limit;
  234. that.$set(that, `skip`, skip)
  235. that.search();
  236. uni.hideLoading();
  237. } else uni.showToast({
  238. title: '没有更多数据了'
  239. });
  240. },
  241. // 清空列表
  242. clearPage() {
  243. const that = this;
  244. that.$set(that, `list`, [])
  245. that.$set(that, `skip`, 0)
  246. that.$set(that, `limit`, 6)
  247. that.$set(that, `page`, 0)
  248. }
  249. }
  250. }
  251. </script>
  252. <style lang="scss">
  253. .main {
  254. display: flex;
  255. flex-direction: column;
  256. width: 100vw;
  257. height: 100vh;
  258. .one {
  259. .list {
  260. display: flex;
  261. flex-direction: row;
  262. justify-content: space-between;
  263. width: 91vw;
  264. border: 0.5vw dashed var(--ff0Color);
  265. margin: 2vw 2vw 0 2vw;
  266. padding: 2vw;
  267. border-radius: 5px;
  268. .image {
  269. width: 25vw;
  270. height: 25vw;
  271. border-radius: 5px;
  272. margin: 0 2vw 0 0;
  273. }
  274. .list_1_1 {
  275. display: flex;
  276. flex-direction: column;
  277. justify-content: space-between;
  278. flex-grow: 1;
  279. padding: 2vw 0;
  280. .name {
  281. font-size: var(--font16Size);
  282. margin: 0 0 1vw 0;
  283. }
  284. .specs {
  285. display: flex;
  286. justify-content: space-between;
  287. color: var(--f85Color);
  288. font-size: var(--font12Size);
  289. }
  290. .money {
  291. color: var(--fFB1Color);
  292. font-size: var(--font14Size);
  293. margin: 0 0 1vw 0;
  294. text:last-child {
  295. font-size: var(--font16Size);
  296. }
  297. }
  298. }
  299. }
  300. }
  301. .two {
  302. margin: 4vw 0 0 0;
  303. button {
  304. margin: 0 2vw 2vw 2vw;
  305. background-color: #FFA500;
  306. color: var(--fffColor);
  307. }
  308. }
  309. .thr {
  310. position: relative;
  311. flex-grow: 1;
  312. .list {
  313. display: flex;
  314. flex-direction: row;
  315. justify-content: space-between;
  316. align-items: center;
  317. width: 91vw;
  318. border: 1px solid var(--f1Color);
  319. margin: 2vw 2vw 0 2vw;
  320. padding: 0 2vw;
  321. border-radius: 5px;
  322. .image {
  323. width: 25vw;
  324. height: 25vw;
  325. border-radius: 5px;
  326. margin: 0 2vw 0 0;
  327. }
  328. .list_1 {
  329. display: flex;
  330. flex-direction: column;
  331. flex-grow: 1;
  332. padding: 2vw 0;
  333. .name {
  334. font-size: var(--font16Size);
  335. margin: 0 0 1vw 0;
  336. }
  337. .some {
  338. color: var(--f85Color);
  339. font-size: var(--font14Size);
  340. margin: 0 0 1vw 0;
  341. text:last-child {
  342. margin: 0 0 0 1vw;
  343. color: var(--f00Color);
  344. }
  345. }
  346. .other {
  347. display: flex;
  348. justify-content: space-between;
  349. align-items: center;
  350. .other_1 {
  351. font-size: var(--font14Size);
  352. color: var(--f85Color);
  353. text {
  354. font-weight: bold;
  355. padding: 0 1vw 0 0;
  356. color: var(--ff0Color);
  357. }
  358. }
  359. .other_2 {
  360. .btn {
  361. display: flex;
  362. flex-direction: column;
  363. align-items: center;
  364. margin: 0 2vw;
  365. padding: 2vw 3vw;
  366. background-color: var(--ff0Color);
  367. color: var(--fffColor);
  368. border-radius: 2vw;
  369. font-size: var(--font14Size);
  370. text {
  371. font-size: var(--font12Size);
  372. }
  373. }
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .scroll-view {
  381. position: absolute;
  382. top: 0;
  383. left: 0;
  384. right: 0;
  385. bottom: 0;
  386. .list-scroll-view {
  387. display: flex;
  388. flex-direction: column;
  389. }
  390. }
  391. .content {
  392. height: 60vw;
  393. .one {
  394. display: flex;
  395. justify-content: flex-start;
  396. align-items: center;
  397. margin: 0 2vw;
  398. padding: 2vw 0;
  399. text {
  400. margin: 0 2vw 0 0;
  401. }
  402. text:last-child {
  403. margin: 0 0 0 2vw;
  404. font-size: var(--font12Size);
  405. color: var(--f85Color);
  406. }
  407. }
  408. .btn {
  409. display: flex;
  410. justify-content: space-between;
  411. position: fixed;
  412. bottom: 0;
  413. .button {
  414. width: 100vw;
  415. padding: 4vw 0;
  416. background-color: var(--fFB1Color);
  417. text-align: center;
  418. font-size: var(--font18Szie);
  419. color: var(--mainColor);
  420. }
  421. }
  422. }
  423. </style>