order.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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.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.search();
  113. }
  114. } catch (e) {
  115. uni.showToast({
  116. title: err.errmsg,
  117. icon: 'error',
  118. duration: 2000
  119. });
  120. }
  121. },
  122. async search() {
  123. const that = this;
  124. let user = that.user;
  125. let info = {
  126. skip: that.skip,
  127. limit: that.limit,
  128. supplier: user._id,
  129. status: '4'
  130. };
  131. let res;
  132. res = await that.$api(`/OrderDetail/queryInfo`, 'GET', {
  133. ...info,
  134. ...that.searchInfo
  135. });
  136. if (res.errcode == '0') {
  137. let list = [...that.list, ...res.data];
  138. for (let val of list) {
  139. val.zhStatus = that.searchStatus(val.status)
  140. }
  141. that.$set(that, `list`, list);
  142. that.$set(that, `total`, res.total)
  143. } else {
  144. uni.showToast({
  145. title: res.errmsg,
  146. icon: 'none'
  147. })
  148. }
  149. },
  150. // 查看详情
  151. toInfo(item) {
  152. console.log(item);
  153. },
  154. // 查询状态
  155. searchStatus(e) {
  156. const that = this;
  157. let data = that.statusList.find((i) => i.value == e);
  158. if (data) return data.label
  159. else return '暂无'
  160. },
  161. // 确认发货
  162. async toConfirm(item) {
  163. const that = this;
  164. let user = that.user;
  165. let obj = {
  166. status: '5'
  167. }
  168. uni.showModal({
  169. title: '提示',
  170. content: '确定发货该订单吗?',
  171. success: async function(res) {
  172. if (res.confirm) {
  173. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  174. if (res.errcode == '0') {
  175. uni.showToast({
  176. title: '维护信息成功',
  177. icon: 'none'
  178. })
  179. that.clearPage()
  180. that.search()
  181. } else {
  182. uni.showToast({
  183. title: res.errmsg,
  184. icon: 'none'
  185. })
  186. }
  187. }
  188. }
  189. });
  190. },
  191. // 分页
  192. toPage(e) {
  193. const that = this;
  194. let list = that.list;
  195. let limit = that.limit;
  196. if (that.total > list.length) {
  197. uni.showLoading({
  198. title: '加载中',
  199. mask: true
  200. })
  201. let page = that.page + 1;
  202. that.$set(that, `page`, page)
  203. let skip = page * limit;
  204. that.$set(that, `skip`, skip)
  205. that.search();
  206. uni.hideLoading();
  207. } else that.$set(that, `is_bottom`, true)
  208. },
  209. // 触底
  210. toScroll(e) {
  211. const that = this;
  212. let up = that.scrollTop;
  213. that.$set(that, `scrollTop`, e.detail.scrollTop);
  214. let num = Math.sign(up - e.detail.scrollTop);
  215. if (num == 1) that.$set(that, `is_bottom`, false);
  216. },
  217. // 输入框
  218. toInput(e) {
  219. const that = this;
  220. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  221. else that.$set(that, `searchInfo`, {})
  222. that.clearPage();
  223. that.search();
  224. },
  225. // 查询其他信息
  226. async searchOther() {
  227. const that = this;
  228. let res;
  229. // 查询状态
  230. res = await that.$api(`/DictData`, 'GET', {
  231. type: 'order_status',
  232. is_use: '0',
  233. })
  234. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  235. },
  236. // 清空列表
  237. clearPage() {
  238. const that = this;
  239. that.$set(that, `list`, [])
  240. that.$set(that, `skip`, 0)
  241. that.$set(that, `limit`, 6)
  242. that.$set(that, `page`, 0)
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss">
  248. .content {
  249. display: flex;
  250. flex-direction: column;
  251. width: 100vw;
  252. height: 100vh;
  253. .one {
  254. padding: 2vw;
  255. input {
  256. padding: 2vw;
  257. background-color: var(--f1Color);
  258. font-size: var(--font14Size);
  259. border-radius: 5px;
  260. }
  261. }
  262. .two {
  263. position: relative;
  264. flex-grow: 1;
  265. background-color: var(--f9Color);
  266. .list {
  267. background-color: #fff;
  268. border: 1px solid var(--f5Color);
  269. padding: 2vw;
  270. margin: 2vw 2vw 0 2vw;
  271. border-radius: 5px;
  272. .list_1 {
  273. display: flex;
  274. justify-content: space-between;
  275. padding: 2vw 0;
  276. font-size: var(--font14Size);
  277. .status {
  278. color: var(--fF0Color);
  279. }
  280. }
  281. .list_2 {
  282. display: flex;
  283. .left {
  284. .image {
  285. width: 20vw;
  286. height: 20vw;
  287. border-radius: 5px;
  288. }
  289. }
  290. .right {
  291. width: 70vw;
  292. margin: 0 0 0 2vw;
  293. .right_1 {
  294. display: flex;
  295. justify-content: space-between;
  296. margin: 2vw 0;
  297. .name {
  298. font-size: var(--font14Size);
  299. }
  300. .num {
  301. display: flex;
  302. flex-direction: column;
  303. align-items: flex-end;
  304. text:last-child {
  305. font-size: var(--font13Size);
  306. color: var(--f85Color);
  307. }
  308. }
  309. }
  310. .right_2 {
  311. font-size: var(--font12Size);
  312. color: var(--f85Color);
  313. }
  314. }
  315. }
  316. .bottom {
  317. text-align: center;
  318. padding: 1vw 0;
  319. button {
  320. margin: 0 5px 0 0;
  321. }
  322. }
  323. }
  324. }
  325. }
  326. .scroll-view {
  327. position: absolute;
  328. top: 0;
  329. left: 0;
  330. right: 0;
  331. bottom: 0;
  332. .list-scroll-view {
  333. display: flex;
  334. flex-direction: column;
  335. }
  336. }
  337. .is_bottom {
  338. text-align: center;
  339. text {
  340. padding: 2vw 0;
  341. display: inline-block;
  342. color: var(--f85Color);
  343. font-size: var(--font14Size);
  344. }
  345. }
  346. </style>