index.vue 6.8 KB

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