order.vue 8.5 KB

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