index.vue 9.8 KB

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