group.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <view class="one_1">
  6. <input type="text" v-model="searchInfo.goods_name" @input="toInput" placeholder="搜索商品">
  7. </view>
  8. <view class="one_2">
  9. <button size="mini" @tap="toDislog">筛选</button>
  10. </view>
  11. </view>
  12. <view class="two">
  13. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  14. <view class="list-scroll-view">
  15. <view class="list" v-for="(item,index) in list" :key="index">
  16. <view class="list_1">
  17. <view class="list_1_1">
  18. <view class="shopname">
  19. <text class="iconfont icon-shangdian"></text>
  20. <text>{{item.shop.name}}</text>
  21. </view>
  22. <view class="status">
  23. {{item.zhStatus||'暂无'}}
  24. </view>
  25. </view>
  26. <view class="list_1_2">
  27. <view class="goods">
  28. <view class="goods_1">
  29. <image class="image"
  30. v-if="item.spec&&item.spec.file&&item.spec.file.length>0"
  31. :src="item.spec&&item.spec.file&&item.spec.file.length>0?item.spec.file[0].url:''"
  32. mode=""></image>
  33. <image class="image" v-else
  34. :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''"
  35. mode=""></image>
  36. </view>
  37. <view class="goods_2">
  38. <view class="goodsname textOver">
  39. {{item.goods.name}}
  40. </view>
  41. <view class="time" v-if="item.leader_name">
  42. 团长:{{item.leader_name}}
  43. </view>
  44. <view class="time">
  45. 开始时间:{{item.start_time}}
  46. </view>
  47. <view class="time">
  48. 结束时间:{{item.end_time}}
  49. </view>
  50. <view class="time">
  51. 人数限制:{{item.person_limit}}人
  52. </view>
  53. <view class="other_2">
  54. 原价:<text>¥{{item.sell_price||'暂无'}}</text>团购价:<text>¥{{item.group_price||'暂无'}}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="btn">
  61. <button type="default" size="mini" @tap.stop="toJion(item)">参加团购</button>
  62. </view>
  63. </view>
  64. <view class="is_bottom" v-if="is_bottom">
  65. <text>{{config.bottom_title}}</text>
  66. </view>
  67. </view>
  68. </scroll-view>
  69. </view>
  70. <view class="dialog" v-if="dialog.show==true">
  71. <view class="dialog_1" v-if="dialog.type=='1'">
  72. <uni-forms ref="form" :modelValue="searchInfo" :rules="rules" label-width="auto">
  73. <uni-forms-item label="会员名称" name="leader_name">
  74. <uni-easyinput type="text" v-model="searchInfo.leader_name" placeholder="请输入会员名称" />
  75. </uni-forms-item>
  76. <uni-forms-item label="开始时间" name="start_time">
  77. <uni-datetime-picker type="datetime" v-model="searchInfo.start_time"
  78. @change="startChange" />
  79. </uni-forms-item>
  80. <uni-forms-item label="结束时间" name="end_time">
  81. <uni-datetime-picker type="datetime" v-model="searchInfo.end_time" @change="endChange" />
  82. </uni-forms-item>
  83. </uni-forms>
  84. <view class="btn">
  85. <button type="primary" @click="onSubmit" size="mini">确定</button>
  86. <button type="primary" @click="dialogClose" size="mini">取消</button>
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </mobile-frame>
  92. </template>
  93. <script>
  94. export default {
  95. data() {
  96. return {
  97. // 店铺id
  98. shop: '',
  99. // 系统设置
  100. config: {},
  101. // 设备信息
  102. system: {},
  103. user: {},
  104. searchInfo: {},
  105. list: [],
  106. total: 0,
  107. skip: 0,
  108. limit: 6,
  109. page: 0,
  110. // 数据是否触底
  111. is_bottom: false,
  112. scrollTop: 0,
  113. // 字典表
  114. statusList: [],
  115. status_name: "",
  116. // 条件弹出框
  117. dialog: {
  118. show: false,
  119. type: '1'
  120. }
  121. };
  122. },
  123. onLoad: async function(e) {
  124. const that = this;
  125. that.searchConfig();
  126. await that.searchOther();
  127. await that.watchlogin();
  128. await that.searchShop();
  129. },
  130. onShow: async function(e) {
  131. const that = this;
  132. },
  133. onPullDownRefresh: async function() {
  134. const that = this;
  135. that.clearPage();
  136. await that.search();
  137. uni.stopPullDownRefresh();
  138. },
  139. methods: {
  140. // 查询基本设置
  141. searchConfig() {
  142. const that = this;
  143. uni.getStorage({
  144. key: 'config',
  145. success: function(res) {
  146. if (res.data) that.$set(that, `config`, res.data)
  147. // 设备平台信息
  148. let config = that.$config;
  149. that.$set(that, `system`, config.system);
  150. },
  151. fail: function(err) {
  152. console.log(err);
  153. }
  154. })
  155. },
  156. // 监听用户是否登录
  157. watchlogin() {
  158. const that = this;
  159. uni.getStorage({
  160. key: 'token',
  161. success: function(res) {
  162. let user = that.$jwt(res.data);
  163. if (user) that.$set(that, `user`, user)
  164. }
  165. })
  166. },
  167. // 开始时间选择
  168. startChange(e) {
  169. const that = this;
  170. that.$set(that.searchInfo, `start_time`, e);
  171. },
  172. // 结束时间选择
  173. endChange(e) {
  174. const that = this;
  175. that.$set(that.searchInfo, `end_time`, e);
  176. },
  177. // 店铺信息
  178. searchShop() {
  179. const that = this;
  180. uni.getStorage({
  181. key: 'shop',
  182. success: async function(res) {
  183. that.$set(that, `shop`, res.data);
  184. await that.search();
  185. }
  186. })
  187. },
  188. async search() {
  189. const that = this;
  190. let info = {
  191. skip: that.skip,
  192. limit: that.limit,
  193. shop: that.shop,
  194. status: '0'
  195. }
  196. let res = await that.$api(`/group/aq`, 'GET', {
  197. ...info,
  198. ...that.searchInfo
  199. }, 'group');
  200. if (res.errcode == '0') {
  201. let list = [...that.list, ...res.data];
  202. for (let val of list) {
  203. if (val.status) val.zhStatus = that.searchStatus(val.status)
  204. }
  205. that.$set(that, `list`, list);
  206. that.$set(that, `total`, res.total)
  207. } else {
  208. uni.showToast({
  209. title: res.errmsg,
  210. icon: 'none'
  211. })
  212. }
  213. },
  214. // 查询状态
  215. searchStatus(e) {
  216. const that = this;
  217. let data = that.statusList.find((i) => i.value == e);
  218. if (data) return data.label
  219. else return '暂无'
  220. },
  221. // 参加团购
  222. toJion(e) {
  223. const that = this;
  224. // that.clearPage();
  225. uni.navigateTo({
  226. url: `/pagesHome/group/share?id=${e.goods._id}&group=${e._id}`
  227. })
  228. },
  229. // 分页
  230. toPage(e) {
  231. const that = this;
  232. let list = that.list;
  233. let limit = that.limit;
  234. if (that.total > list.length) {
  235. uni.showLoading({
  236. title: '加载中',
  237. mask: true
  238. })
  239. let page = that.page + 1;
  240. that.$set(that, `page`, page)
  241. let skip = page * limit;
  242. that.$set(that, `skip`, skip)
  243. that.search();
  244. uni.hideLoading();
  245. } else that.$set(that, `is_bottom`, true)
  246. },
  247. toScroll(e) {
  248. const that = this;
  249. let up = that.scrollTop;
  250. that.$set(that, `scrollTop`, e.detail.scrollTop);
  251. let num = Math.sign(up - e.detail.scrollTop);
  252. if (num == 1) that.$set(that, `is_bottom`, false);
  253. },
  254. // 查询条件
  255. toDislog() {
  256. const that = this;
  257. that.$set(that, `searchInfo`, {})
  258. that.$set(that, `status_name`, '')
  259. that.$set(that, `dialog`, {
  260. show: true,
  261. type: '1'
  262. })
  263. },
  264. // 状态选择
  265. statusChange(e) {
  266. const that = this;
  267. let data = that.statusList[e.detail.value];
  268. if (data) {
  269. that.$set(that.searchInfo, `status`, data.value);
  270. that.$set(that, `status_name`, data.label);
  271. }
  272. },
  273. // 关闭弹框
  274. dialogClose() {
  275. const that = this;
  276. that.clearPage();
  277. that.search();
  278. that.$set(that, `dialog`, {
  279. show: false,
  280. type: '1'
  281. })
  282. },
  283. // 查询
  284. onSubmit() {
  285. const that = this;
  286. that.clearPage();
  287. that.search();
  288. that.$set(that, `dialog`, {
  289. show: false,
  290. type: '1'
  291. })
  292. },
  293. // 查询其他信息
  294. async searchOther() {
  295. const that = this;
  296. let res;
  297. // 查询状态
  298. res = await that.$api(`/dictData`, 'GET', {
  299. code: 'group_status'
  300. })
  301. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  302. },
  303. // 输入框
  304. toInput(e) {
  305. const that = this;
  306. if (that.searchInfo.goods_name) that.$set(that.searchInfo, `goods_name`, e.detail.value)
  307. else that.$set(that, `searchInfo`, {})
  308. that.clearPage();
  309. that.search();
  310. },
  311. // 清空列表
  312. clearPage() {
  313. const that = this;
  314. that.$set(that, `list`, [])
  315. that.$set(that, `skip`, 0)
  316. that.$set(that, `limit`, 6)
  317. that.$set(that, `page`, 0)
  318. }
  319. },
  320. }
  321. </script>
  322. <style lang="scss">
  323. .main {
  324. display: flex;
  325. flex-direction: column;
  326. width: 100vw;
  327. height: 100vh;
  328. .one {
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. padding: 2vw;
  333. .one_1 {
  334. padding: 0 2vw;
  335. width: 75vw;
  336. input {
  337. padding: 2vw;
  338. background-color: var(--f1Color);
  339. font-size: var(--font14Size);
  340. border-radius: 5px;
  341. }
  342. }
  343. button {
  344. background-color: #23B67A;
  345. color: #ffffff;
  346. }
  347. }
  348. .two {
  349. position: relative;
  350. flex-grow: 1;
  351. background-color: var(--f9Color);
  352. .list {
  353. background-color: #fff;
  354. border: 1px solid var(--f5Color);
  355. padding: 2vw;
  356. margin: 0 2vw 2vw 2vw;
  357. border-radius: 5px;
  358. .list_1 {
  359. .list_1_1 {
  360. display: flex;
  361. justify-content: space-between;
  362. margin: 0 0 2vw 0;
  363. .shopname {
  364. text:last-child {
  365. padding: 0 0 0 2vw;
  366. }
  367. }
  368. .status {
  369. color: var(--fFB1Color);
  370. }
  371. }
  372. .list_1_2 {
  373. border-bottom: 1px solid #f1f1f1;
  374. .goods {
  375. display: flex;
  376. padding: 0 0 2vw 0;
  377. .goods_1 {
  378. width: 20vw;
  379. height: 20vw;
  380. .image {
  381. width: 100%;
  382. height: 100%;
  383. border-radius: 5px;
  384. }
  385. }
  386. .goods_2 {
  387. width: 70vw;
  388. padding: 0 0 0 2vw;
  389. .goodsname {
  390. font-size: 16px;
  391. margin: 0 0 1vw 0;
  392. }
  393. .time {
  394. font-size: 14px;
  395. color: #858585;
  396. }
  397. .other_2 {
  398. color: #858585;
  399. font-size: var(--font14Size);
  400. text {
  401. color: var(--fFB1Color);
  402. padding: 0 2vw 0 0;
  403. }
  404. }
  405. }
  406. }
  407. }
  408. .other {
  409. padding: 0 0 2vw 0;
  410. margin: 2vw 0;
  411. text-align: right;
  412. border-bottom: 1px solid #f1f1f1;
  413. text {
  414. font-size: 14px;
  415. padding: 0 0 0 2vw;
  416. }
  417. }
  418. }
  419. .btn {
  420. text-align: right;
  421. margin: 1vw 0 0 0;
  422. button {
  423. margin: 0 1vw 0 0;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. .dialog {
  430. position: fixed;
  431. width: 96vw;
  432. height: 100vh;
  433. background-color: #ffffff;
  434. z-index: 99999;
  435. display: flex;
  436. flex-direction: column;
  437. padding: 2vw;
  438. .uni-input {
  439. border: #f1f1ff 1px solid;
  440. padding: 2vw 2vw;
  441. border-radius: 1vw;
  442. }
  443. .picker {
  444. border: 1px solid #3333;
  445. border-radius: 5px;
  446. padding: 2vw;
  447. }
  448. .btn {
  449. text-align: center;
  450. button {
  451. margin: 0 2vw 2vw 2vw;
  452. background-color: #23B67A;
  453. color: #ffffff;
  454. }
  455. .name {
  456. color: var(--f85Color);
  457. font-size: var(--font14Size);
  458. }
  459. }
  460. }
  461. .scroll-view {
  462. position: absolute;
  463. top: 0;
  464. left: 0;
  465. right: 0;
  466. bottom: 0;
  467. .list-scroll-view {
  468. display: flex;
  469. flex-direction: column;
  470. }
  471. }
  472. .is_bottom {
  473. text-align: center;
  474. text {
  475. padding: 2vw 0;
  476. display: inline-block;
  477. color: #858585;
  478. font-size: 14px;
  479. }
  480. }
  481. </style>