order.vue 8.9 KB

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