index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <input type="text" v-model="searchInfo.goods" @blur="toInput" placeholder="搜索商品">
  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="shopname">
  13. <text class="iconfont icon-shangdian"></text>
  14. <text>{{item.shop.name}}</text>
  15. </view>
  16. </view>
  17. <view class="list_2">
  18. <view class="market">
  19. <view class="url">
  20. <image class="image" :src="item.goods.file&&item.goods.file.length>0?item.goods.file[0].url:''" mode=""></image>
  21. </view>
  22. <view class="name">
  23. {{item.goods.name}}
  24. <view class="specs">
  25. {{item.zhStatus}}
  26. </view>
  27. <view class="specs">
  28. 购买时间:{{item.buy_time}}
  29. </view>
  30. <view class="specs">
  31. 备注:{{item.remarks||'暂无'}}
  32. </view>
  33. </view>
  34. <view class="other">
  35. <view class="price">
  36. {{item.goods.cost}}
  37. </view>
  38. <view class="num">
  39. ×{{item.buy_num}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="btn">
  45. <button v-if="item.status=='2'||item.status=='3'" type="default" size="mini" @click="toLogi(item)">查看物流</button>
  46. </view>
  47. </view>
  48. <view class="is_bottom" v-if="is_bottom">
  49. <text>{{config.bottom_title}}</text>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </view>
  55. </mobile-frame>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. // 系统设置
  62. config: {},
  63. searchInfo: {},
  64. user: {},
  65. list: [],
  66. total: 0,
  67. skip: 0,
  68. limit: 10,
  69. page: 0,
  70. // 状态
  71. statusList: [],
  72. // 数据是否触底
  73. is_bottom: false,
  74. scrollTop: 0,
  75. };
  76. },
  77. onShow: async function() {
  78. const that = this;
  79. that.searchConfig();
  80. await that.searchOther();
  81. await that.watchLogin();
  82. },
  83. onHide: function() {
  84. const that = this;
  85. that.clearPage();
  86. },
  87. onPullDownRefresh: async function() {
  88. const that = this;
  89. that.clearPage();
  90. await that.search();
  91. uni.stopPullDownRefresh();
  92. },
  93. methods: {
  94. // 查询基本设置
  95. searchConfig() {
  96. const that = this;
  97. uni.getStorage({
  98. key: 'config',
  99. success: function(res) {
  100. if (res.data) that.$set(that, `config`, res.data)
  101. },
  102. fail: function(err) {
  103. console.log(err);
  104. }
  105. })
  106. },
  107. watchLogin() {
  108. const that = this;
  109. uni.getStorage({
  110. key: 'token',
  111. success: function(res) {
  112. let user = that.$jwt(res.data);
  113. that.$set(that, `user`, user)
  114. that.search()
  115. }
  116. })
  117. },
  118. // 查询列表
  119. async search() {
  120. const that = this;
  121. let user = that.user;
  122. if (user._id) {
  123. let info = {
  124. skip: that.skip,
  125. limit: that.limit,
  126. customer: user._id,
  127. }
  128. let res = await that.$api(`/zrOrder`, 'GET', {
  129. ...info,
  130. ...that.searchInfo
  131. }, `integral`)
  132. if (res.errcode == '0') {
  133. let list = [...that.list, ...res.data];
  134. for (let val of list) {
  135. let status = that.statusList.find(i => i.value == val.status)
  136. if (status) val.zhStatus = status.label;
  137. }
  138. that.$set(that, `list`, list);
  139. that.$set(that, `total`, res.total)
  140. }
  141. }
  142. },
  143. // 查询其他信息
  144. async searchOther() {
  145. const that = this;
  146. let res;
  147. res = await that.$api(`/dictData`, 'GET', {
  148. code: "order_process"
  149. });
  150. if (res.errcode == '0') {
  151. that.$set(that, `statusList`, res.data)
  152. }
  153. },
  154. // 分页
  155. toPage(e) {
  156. const that = this;
  157. let list = that.list;
  158. let limit = that.limit;
  159. if (that.total > list.length) {
  160. uni.showLoading({
  161. title: '加载中',
  162. mask: true
  163. })
  164. let page = that.page + 1;
  165. that.$set(that, `page`, page)
  166. let skip = page * limit;
  167. that.$set(that, `skip`, skip)
  168. that.search();
  169. uni.hideLoading();
  170. } else that.$set(that, `is_bottom`, true)
  171. },
  172. toScroll(e) {
  173. const that = this;
  174. let up = that.scrollTop;
  175. that.$set(that, `scrollTop`, e.detail.scrollTop);
  176. let num = Math.sign(up - e.detail.scrollTop);
  177. if (num == 1) that.$set(that, `is_bottom`, false);
  178. },
  179. // 输入框
  180. toInput(e) {
  181. const that = this;
  182. if (e.detail.value == '') {
  183. that.$set(that, `searchInfo`, {})
  184. } else {
  185. that.$set(that.searchInfo, `goods`, e.detail.value);
  186. }
  187. that.clearPage();
  188. that.search();
  189. },
  190. // 查看物流
  191. toLogi(e) {
  192. uni.navigateTo({
  193. url: `/pagesMy/logistics/index?id=${e._id}&type=${'integral'}`
  194. })
  195. },
  196. // 清空列表
  197. clearPage() {
  198. const that = this;
  199. that.$set(that, `list`, [])
  200. that.$set(that, `skip`, 0)
  201. that.$set(that, `limit`, 6)
  202. that.$set(that, `page`, 0)
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. .main {
  209. display: flex;
  210. flex-direction: column;
  211. width: 100vw;
  212. height: 100vh;
  213. .one {
  214. border-bottom: 1px solid var(--f85Color);
  215. padding: 2vw;
  216. input {
  217. padding: 2vw;
  218. background-color: var(--f1Color);
  219. font-size: var(--font14Size);
  220. border-radius: 5px;
  221. }
  222. }
  223. .two {
  224. position: relative;
  225. flex-grow: 1;
  226. padding: 2vw 0 0 0;
  227. .list {
  228. width: 92vw;
  229. border: 0.5vw solid var(--f1Color);
  230. margin: 2vw 2vw 0 1.5vw;
  231. padding: 2vw;
  232. border-radius: 5px;
  233. .list_1 {
  234. margin: 0 0 2vw 0;
  235. .shopname {
  236. text:last-child {
  237. padding: 0 0 0 2vw;
  238. }
  239. }
  240. }
  241. .list_2 {
  242. margin: 0 0 1vw 0;
  243. .market {
  244. display: flex;
  245. .url {
  246. width: 20vw;
  247. .image {
  248. width: 100%;
  249. height: 20vw;
  250. border-radius: 5px;
  251. }
  252. }
  253. .name {
  254. display: flex;
  255. flex-direction: column;
  256. width: 60vw;
  257. padding: 0 2vw;
  258. margin: 0 0 1vw 0;
  259. .specs {
  260. color: var(--f85Color);
  261. font-size: var(--font12Size);
  262. }
  263. }
  264. .other {
  265. width: 15vw;
  266. text-align: right;
  267. .price {
  268. color: var(--fFB1Color);
  269. }
  270. }
  271. }
  272. }
  273. .btn {
  274. text-align: right;
  275. margin: 2vw 0 0 0;
  276. button {
  277. margin: 2vw 0 0 2vw;
  278. }
  279. }
  280. }
  281. }
  282. }
  283. .scroll-view {
  284. position: absolute;
  285. top: 0;
  286. left: 0;
  287. right: 0;
  288. bottom: 0;
  289. .list-scroll-view {
  290. display: flex;
  291. flex-direction: column;
  292. }
  293. }
  294. .is_bottom {
  295. text-align: center;
  296. text {
  297. padding: 2vw 0;
  298. display: inline-block;
  299. color: #858585;
  300. font-size: 14px;
  301. }
  302. }
  303. </style>