group.vue 11 KB

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