group.vue 11 KB

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