group.vue 9.4 KB

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