group.vue 11 KB

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