order.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.goods" @input="toInput" placeholder="搜索商品">
  5. </view>
  6. <view class="two">
  7. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  8. <view class="list-scroll-view">
  9. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  10. <view class="list_1">
  11. <text>
  12. <text class="iconfont icon-changshangguanli"></text>
  13. {{item.supplier_name}}
  14. </text>
  15. <text class="status">{{item.zhStatus}}</text>
  16. </view>
  17. <view class="list_2">
  18. <view class="left">
  19. <image v-if="item.spec_file" class="image" :src="item.spec_file?item.spec_file.url:''"
  20. mode="">
  21. </image>
  22. <image v-else class="image" :src="item.good_file?item.good_file.url:''" mode="">
  23. </image>
  24. </view>
  25. <view class="right">
  26. <view class="right_1">
  27. <view class="name textOver">
  28. <text>{{item.good_name||'暂无'}}</text>
  29. </view>
  30. <view class="num">
  31. <text>¥{{item.total_money||'0'}}</text>
  32. <text>×{{item.num||'0'}}</text>
  33. </view>
  34. </view>
  35. <view class="right_2">
  36. <view class="spec textOver">
  37. <text>规格:{{item.spec_name||'暂无'}}</text>
  38. </view>
  39. <view class="spec textOver">
  40. <text>购买用户:{{item.user_name||'暂无'}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="bottom">
  46. <button size="mini" type="default" @tap.stop="toConfirm(item)">确认发货</button>
  47. </view>
  48. </view>
  49. <view class="is_bottom" v-if="is_bottom">
  50. <text>{{config.bottom_title}}</text>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. // 系统设置
  62. config: {},
  63. user: {},
  64. searchInfo: {},
  65. list: [],
  66. total: 0,
  67. skip: 0,
  68. limit: 6,
  69. page: 0,
  70. // 数据是否触底
  71. is_bottom: false,
  72. scrollTop: 0,
  73. // 字典表
  74. statusList: [],
  75. }
  76. },
  77. onLoad: function(e) {
  78. const that = this;
  79. that.searchConfig();
  80. },
  81. onShow: async function(e) {
  82. const that = this;
  83. await that.searchOther();
  84. that.searchToken();
  85. },
  86. onPullDownRefresh: async function() {
  87. const that = this;
  88. that.clearPage();
  89. await that.search();
  90. uni.stopPullDownRefresh();
  91. },
  92. methods: {
  93. searchConfig() {
  94. const that = this;
  95. try {
  96. const res = uni.getStorageSync('config');
  97. if (res) that.$set(that, `config`, res);
  98. } catch (e) {
  99. uni.showToast({
  100. title: err.errmsg,
  101. icon: 'error',
  102. duration: 2000
  103. });
  104. }
  105. },
  106. searchToken() {
  107. const that = this;
  108. try {
  109. const res = uni.getStorageSync('token');
  110. if (res) {
  111. that.$set(that, `user`, res);
  112. that.clearPage();
  113. that.search();
  114. }
  115. } catch (e) {
  116. uni.showToast({
  117. title: err.errmsg,
  118. icon: 'error',
  119. duration: 2000
  120. });
  121. }
  122. },
  123. async search() {
  124. const that = this;
  125. let user = that.user;
  126. let info = {
  127. skip: that.skip,
  128. limit: that.limit,
  129. supplier: user._id,
  130. status: '4'
  131. };
  132. let res;
  133. res = await that.$api(`/OrderDetail/queryInfo`, 'GET', {
  134. ...info,
  135. ...that.searchInfo
  136. });
  137. if (res.errcode == '0') {
  138. let list = [...that.list, ...res.data];
  139. for (let val of list) {
  140. val.zhStatus = that.searchStatus(val.status)
  141. }
  142. that.$set(that, `list`, list);
  143. that.$set(that, `total`, res.total)
  144. } else {
  145. uni.showToast({
  146. title: res.errmsg,
  147. icon: 'none'
  148. })
  149. }
  150. },
  151. // 查看详情
  152. toInfo(e) {
  153. uni.navigateTo({
  154. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  155. })
  156. },
  157. // 查询状态
  158. searchStatus(e) {
  159. const that = this;
  160. let data = that.statusList.find((i) => i.value == e);
  161. if (data) return data.label
  162. else return '暂无'
  163. },
  164. // 确认发货
  165. async toConfirm(item) {
  166. const that = this;
  167. let user = that.user;
  168. let obj = {
  169. status: '5'
  170. }
  171. uni.showModal({
  172. title: '提示',
  173. content: '确定发货该订单吗?',
  174. success: async function(res) {
  175. if (res.confirm) {
  176. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  177. if (res.errcode == '0') {
  178. uni.showToast({
  179. title: '维护信息成功',
  180. icon: 'none'
  181. })
  182. that.clearPage()
  183. that.search()
  184. } else {
  185. uni.showToast({
  186. title: res.errmsg,
  187. icon: 'none'
  188. })
  189. }
  190. }
  191. }
  192. });
  193. },
  194. // 分页
  195. toPage(e) {
  196. const that = this;
  197. let list = that.list;
  198. let limit = that.limit;
  199. if (that.total > list.length) {
  200. uni.showLoading({
  201. title: '加载中',
  202. mask: true
  203. })
  204. let page = that.page + 1;
  205. that.$set(that, `page`, page)
  206. let skip = page * limit;
  207. that.$set(that, `skip`, skip)
  208. that.search();
  209. uni.hideLoading();
  210. } else that.$set(that, `is_bottom`, true)
  211. },
  212. // 触底
  213. toScroll(e) {
  214. const that = this;
  215. let up = that.scrollTop;
  216. that.$set(that, `scrollTop`, e.detail.scrollTop);
  217. let num = Math.sign(up - e.detail.scrollTop);
  218. if (num == 1) that.$set(that, `is_bottom`, false);
  219. },
  220. // 输入框
  221. toInput(e) {
  222. const that = this;
  223. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  224. else that.$set(that, `searchInfo`, {})
  225. that.clearPage();
  226. that.search();
  227. },
  228. // 查询其他信息
  229. async searchOther() {
  230. const that = this;
  231. let res;
  232. // 查询状态
  233. res = await that.$api(`/DictData`, 'GET', {
  234. type: 'order_status',
  235. is_use: '0',
  236. })
  237. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  238. },
  239. // 清空列表
  240. clearPage() {
  241. const that = this;
  242. that.$set(that, `list`, [])
  243. that.$set(that, `skip`, 0)
  244. that.$set(that, `limit`, 6)
  245. that.$set(that, `page`, 0)
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss">
  251. .content {
  252. display: flex;
  253. flex-direction: column;
  254. width: 100vw;
  255. height: 100vh;
  256. .one {
  257. padding: 2vw;
  258. input {
  259. padding: 2vw;
  260. background-color: var(--f1Color);
  261. font-size: var(--font14Size);
  262. border-radius: 5px;
  263. }
  264. }
  265. .two {
  266. position: relative;
  267. flex-grow: 1;
  268. background-color: var(--f9Color);
  269. .list {
  270. background-color: #fff;
  271. border: 1px solid var(--f5Color);
  272. padding: 2vw;
  273. margin: 2vw 2vw 0 2vw;
  274. border-radius: 5px;
  275. .list_1 {
  276. display: flex;
  277. justify-content: space-between;
  278. padding: 2vw 0;
  279. font-size: var(--font14Size);
  280. .status {
  281. color: var(--fF0Color);
  282. }
  283. }
  284. .list_2 {
  285. display: flex;
  286. .left {
  287. .image {
  288. width: 20vw;
  289. height: 20vw;
  290. border-radius: 5px;
  291. }
  292. }
  293. .right {
  294. width: 70vw;
  295. margin: 0 0 0 2vw;
  296. .right_1 {
  297. display: flex;
  298. justify-content: space-between;
  299. margin: 2vw 0;
  300. .name {
  301. font-size: var(--font14Size);
  302. }
  303. .num {
  304. display: flex;
  305. flex-direction: column;
  306. align-items: flex-end;
  307. text:last-child {
  308. font-size: var(--font13Size);
  309. color: var(--f85Color);
  310. }
  311. }
  312. }
  313. .right_2 {
  314. font-size: var(--font12Size);
  315. color: var(--f85Color);
  316. }
  317. }
  318. }
  319. .bottom {
  320. text-align: center;
  321. padding: 1vw 0;
  322. button {
  323. margin: 0 5px 0 0;
  324. }
  325. }
  326. }
  327. }
  328. }
  329. .scroll-view {
  330. position: absolute;
  331. top: 0;
  332. left: 0;
  333. right: 0;
  334. bottom: 0;
  335. .list-scroll-view {
  336. display: flex;
  337. flex-direction: column;
  338. }
  339. }
  340. .is_bottom {
  341. text-align: center;
  342. text {
  343. padding: 2vw 0;
  344. display: inline-block;
  345. color: var(--f85Color);
  346. font-size: var(--font14Size);
  347. }
  348. }
  349. </style>