index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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=='-7'||item.status=='-8'" size="mini" type="default"
  53. @tap.stop="toExam(item)">重新申请回款</button>
  54. <button v-if="item.status=='8'||item.status=='9'" size="mini" type="default"
  55. @tap.stop="toCollection(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. };
  141. let res;
  142. res = await that.$api(`/OrderDetail/money`, 'GET', {
  143. ...info,
  144. ...that.searchInfo
  145. });
  146. if (res.errcode == '0') {
  147. let list = [...that.list, ...res.data];
  148. for (let val of list) {
  149. val.zhStatus = that.searchDict(val.status, 'status')
  150. val.zhRole = that.searchDict(val.user_role, 'role')
  151. }
  152. that.$set(that, `list`, list);
  153. that.$set(that, `total`, res.total)
  154. } else {
  155. uni.showToast({
  156. title: res.errmsg,
  157. icon: 'none'
  158. })
  159. }
  160. },
  161. // 查看详情
  162. toInfo(e) {
  163. uni.navigateTo({
  164. url: `/pagesMy/order/detail?id=${e.id||e._id}`
  165. })
  166. },
  167. // 查询字典表
  168. searchDict(e, model) {
  169. const that = this;
  170. let data
  171. if (model == 'status') {
  172. data = that.statusList.find((i) => i.value == e);
  173. if (data) return data.label
  174. else return '暂无'
  175. } else if (model == 'role') {
  176. data = that.roleList.find((i) => i.code == e);
  177. if (data) return data.name
  178. else return '暂无'
  179. }
  180. },
  181. // 分页
  182. toPage(e) {
  183. const that = this;
  184. let list = that.list;
  185. let limit = that.limit;
  186. if (that.total > list.length) {
  187. uni.showLoading({
  188. title: '加载中',
  189. mask: true
  190. })
  191. let page = that.page + 1;
  192. that.$set(that, `page`, page)
  193. let skip = page * limit;
  194. that.$set(that, `skip`, skip)
  195. that.search();
  196. uni.hideLoading();
  197. } else that.$set(that, `is_bottom`, true)
  198. },
  199. // 触底
  200. toScroll(e) {
  201. const that = this;
  202. let up = that.scrollTop;
  203. that.$set(that, `scrollTop`, e.detail.scrollTop);
  204. let num = Math.sign(up - e.detail.scrollTop);
  205. if (num == 1) that.$set(that, `is_bottom`, false);
  206. },
  207. // 输入框
  208. toInput(e) {
  209. const that = this;
  210. if (that.searchInfo.goods) that.$set(that.searchInfo, `goods`, e.detail.value)
  211. else that.$set(that, `searchInfo`, {})
  212. that.clearPage();
  213. that.search();
  214. },
  215. // 回款确认
  216. async toCollection(item) {
  217. const that = this;
  218. let user = that.user;
  219. let obj = {
  220. status: '10'
  221. };
  222. uni.showModal({
  223. title: '提示',
  224. content: '确定回款成功吗?',
  225. success: async function(res) {
  226. if (res.confirm) {
  227. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  228. if (res.errcode == '0') {
  229. uni.showToast({
  230. title: '维护信息成功',
  231. icon: 'none'
  232. })
  233. that.clearPage()
  234. that.search()
  235. } else {
  236. uni.showToast({
  237. title: res.errmsg,
  238. icon: 'none'
  239. })
  240. }
  241. }
  242. }
  243. });
  244. },
  245. // 重新申请回款
  246. async toExam(item) {
  247. const that = this;
  248. let user = that.user;
  249. let obj = {
  250. status: '6'
  251. };
  252. uni.showModal({
  253. title: '提示',
  254. content: '确定重新申请该订单吗?',
  255. success: async function(res) {
  256. if (res.confirm) {
  257. const res = await that.$api(`/OrderDetail/${item._id}`, 'POST', obj);
  258. if (res.errcode == '0') {
  259. uni.showToast({
  260. title: '维护信息成功',
  261. icon: 'none'
  262. })
  263. that.clearPage()
  264. that.search()
  265. } else {
  266. uni.showToast({
  267. title: res.errmsg,
  268. icon: 'none'
  269. })
  270. }
  271. }
  272. }
  273. });
  274. },
  275. // 查询其他信息
  276. async searchOther() {
  277. const that = this;
  278. let res;
  279. // 查询状态
  280. res = await that.$api(`/DictData`, 'GET', {
  281. type: 'order_status',
  282. is_use: '0',
  283. })
  284. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  285. // 查询角色
  286. res = await that.$api(`/Role`, 'GET', {
  287. is_use: '0',
  288. })
  289. if (res.errcode == '0') that.$set(that, `roleList`, res.data);
  290. },
  291. // 清空列表
  292. clearPage() {
  293. const that = this;
  294. that.$set(that, `list`, [])
  295. that.$set(that, `skip`, 0)
  296. that.$set(that, `limit`, 6)
  297. that.$set(that, `page`, 0)
  298. }
  299. }
  300. }
  301. </script>
  302. <style lang="scss">
  303. .content {
  304. display: flex;
  305. flex-direction: column;
  306. width: 100vw;
  307. height: 100vh;
  308. .one {
  309. padding: 2vw;
  310. input {
  311. padding: 2vw;
  312. background-color: var(--f1Color);
  313. font-size: var(--font14Size);
  314. border-radius: 5px;
  315. }
  316. }
  317. .two {
  318. position: relative;
  319. flex-grow: 1;
  320. background-color: var(--f9Color);
  321. .list {
  322. background-color: #fff;
  323. border: 1px solid var(--f5Color);
  324. padding: 2vw;
  325. margin: 2vw 2vw 0 2vw;
  326. border-radius: 5px;
  327. .list_1 {
  328. display: flex;
  329. justify-content: space-between;
  330. padding: 2vw 0;
  331. font-size: var(--font16Size);
  332. .status {
  333. font-size: var(--font14Size);
  334. color: var(--fF0Color);
  335. }
  336. }
  337. .list_2 {
  338. display: flex;
  339. .left {
  340. .image {
  341. width: 20vw;
  342. height: 20vw;
  343. border-radius: 5px;
  344. border: 1px solid var(--f9Color);
  345. }
  346. }
  347. .right {
  348. width: 70vw;
  349. margin: 0 0 0 2vw;
  350. .right_1 {
  351. display: flex;
  352. justify-content: space-between;
  353. margin: 0 0 2vw 0;
  354. .name {
  355. font-size: var(--font14Size);
  356. }
  357. .num {
  358. display: flex;
  359. flex-direction: column;
  360. align-items: flex-end;
  361. text:last-child {
  362. font-size: var(--font13Size);
  363. color: var(--f85Color);
  364. }
  365. }
  366. }
  367. .right_2 {
  368. font-size: var(--font12Size);
  369. .spec {
  370. text:first-child {
  371. color: var(--f85Color);
  372. }
  373. }
  374. }
  375. }
  376. }
  377. .bottom {
  378. text-align: center;
  379. padding: 1vw 0;
  380. button {
  381. margin: 0 5px 0 0;
  382. }
  383. }
  384. }
  385. }
  386. }
  387. .scroll-view {
  388. position: absolute;
  389. top: 0;
  390. left: 0;
  391. right: 0;
  392. bottom: 0;
  393. .list-scroll-view {
  394. display: flex;
  395. flex-direction: column;
  396. }
  397. }
  398. .is_bottom {
  399. width: 100%;
  400. text-align: center;
  401. text {
  402. padding: 2vw 0;
  403. display: inline-block;
  404. color: var(--f85Color);
  405. font-size: var(--font14Size);
  406. }
  407. }
  408. </style>