index.vue 6.7 KB

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