金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

405 lines
10 KiB

  1. <template>
  2. <view>
  3. <lf-nav title="订单管理" :showIcon="true" bgColor="#fff" @changeHeight="e => nav_height = e"></lf-nav>
  4. <view class="head">
  5. <u-tabs :list="tab_list" active-color="#0F31A3" inactive-color='#777777' :is-scroll="true" :current="tab_current" @change="tabChange"></u-tabs>
  6. </view>
  7. <swiper :style="{height: autoHeight}" :current="tab_current" @change="swiperChange">
  8. <swiper-item v-for="(tab_item, tab_index) in tab_list" :key="tab_index">
  9. <scroll-view :style="{height: autoHeight}"
  10. :scroll-y="true"
  11. @scrolltolower="scrolltolower"
  12. :refresher-enabled="true"
  13. :refresher-triggered="tab_item.isRefresher"
  14. @refresherrefresh="refresherrefresh">
  15. <view class="content">
  16. <view class="card" v-for="(item, index) in tab_item.list" :key="index">
  17. <view class="lf-flex">
  18. <image class="goods-img" :src="item.items[0].item_meta.image"></image>
  19. <view class="info">
  20. <view class="lf-font-26 lf-color-333 lf-line-2">{{ item.items[0].item_name }}</view>
  21. <view class="lf-row-between" style="line-height: 1;">
  22. <text class="lf-font-24 lf-color-777">{{ item.count }}{{ item.items[0].item_meta.specs_text }}</text>
  23. <!-- <text class="lf-font-32 lf-font-bold" style="color: #F63434;" v-if="item.payment != null">¥{{ item.payment.amount_yuan }}</text> -->
  24. <text class="lf-font-32 lf-font-bold" style="color: #F63434;">¥{{ item.items[0].unit_price }}</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="order-num">
  29. <view class="deliver" v-if="item.status_text == '待发货'" @click="deliver(item.order_no)">发货</view>
  30. <view v-else>{{ item.status_text }}</view>
  31. <view style="color: #F63434;" @click="removeOrder(item.order_no, tab_index, index)">取消订单</view>
  32. </view>
  33. </view>
  34. <lf-nocontent src="/static/images/empty.png" v-if="tab_item.list.length <= 0"></lf-nocontent>
  35. </view>
  36. </scroll-view>
  37. </swiper-item>
  38. </swiper>
  39. <u-popup mode="bottom" v-model="show_deliver" :round="true" borderRadius="20">
  40. <view class="popup-content">
  41. <view class="title">选择物流商家</view>
  42. <picker mode="selector" range-key="name" :range="columns" :value="select_index" @change="selectChange">
  43. <view class="logistics">
  44. <text>{{ (columns[select_index] && columns[select_index].name) || '请选择物流' }}</text>
  45. <text class="lf-iconfont icon-jiazai load-a" v-if="logistics_load"></text>
  46. <text class="lf-iconfont icon-xiangxia" v-else></text>
  47. </view>
  48. </picker>
  49. <view class="title">快递单号</view>
  50. <input class="input" placeholder="请输入快递单号" v-model="expressNum" />
  51. <button class="btn" @click="confirm">确认发货</button>
  52. </view>
  53. </u-popup>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data(){
  59. let _public = {
  60. page: 1,
  61. isPage: true,
  62. loadingClass: true,
  63. loadingText: '正在加载中',
  64. isRefresher: false
  65. }
  66. return {
  67. tab_current: 0,
  68. tab_list: [{
  69. name: '全部',
  70. list: [],
  71. ..._public
  72. },{
  73. name: '待付款',
  74. list: [],
  75. ..._public
  76. },{
  77. name: '待发货',
  78. list: [],
  79. ..._public
  80. },{
  81. name: '待提货',
  82. list: [],
  83. ..._public
  84. }],
  85. scrollH: 0,
  86. nav_height: 0,
  87. show_deliver: false,
  88. columns: [],
  89. show_logistics: false,
  90. select_index: null,
  91. expressNum: '',
  92. token: '',
  93. logistics_load: true,
  94. click_order_no: ''
  95. }
  96. },
  97. computed: {
  98. autoHeight(){
  99. return `calc(${this.scrollH}px - ${this.nav_height}px - 86rpx)`;
  100. }
  101. },
  102. onLoad(){
  103. let info = uni.getSystemInfoSync();
  104. this.scrollH = info.screenHeight;
  105. this.token = this.$cookieStorage.get('store_token');
  106. this.getOrderList();
  107. },
  108. methods: {
  109. getOrderList(options = {}){
  110. let tabItem = this.tab_list[this.tab_current];
  111. this.$http.get({
  112. api: 'api/supplier/order',
  113. data: {
  114. status: String(this.tab_current)
  115. },
  116. header: {
  117. token: this.token
  118. }
  119. }).then(res => {
  120. console.log("getOrderList", res);
  121. tabItem.isPage = this.$isRight(res.data.next_page_url);
  122. if(options.refresher){
  123. tabItem.isRefresher = false;
  124. this.$msg('刷新成功', {icon: 'success'});
  125. }
  126. if(!tabItem.isPage){
  127. tabItem.loadingClass = false;
  128. tabItem.loadingText = '已加载全部数据~'
  129. }
  130. if(tabItem.page == 1){
  131. tabItem.list = res.data.data.data;
  132. }else{
  133. tabItem.list.push(...res.data.data.data);
  134. }
  135. console.log("this.tab_list", this.tab_list)
  136. })
  137. },
  138. tabChange(event){
  139. this.tab_current = event;
  140. if(this.tab_list[this.tab_current].list.length <= 0){
  141. this.getOrderList();
  142. }
  143. },
  144. swiperChange(event){
  145. this.tab_current = event.detail.current;
  146. if(event.detail.source){
  147. if(this.tab_list[this.tab_current].list.length <= 0){
  148. this.getOrderList();
  149. }
  150. }
  151. },
  152. // 物流
  153. getLogistics(){
  154. this.logistics_load = true;
  155. this.$http.get({
  156. api: 'api/supplier/order/send_list',
  157. data: {
  158. order_no: this.click_order_no
  159. },
  160. header: {
  161. token: this.token
  162. }
  163. }).then(res => {
  164. if(res.data.code == 200){
  165. this.logistics_load = false;
  166. this.columns = res.data.data;
  167. }
  168. })
  169. },
  170. deliver(order_no){
  171. console.log("1111111");
  172. this.show_deliver = true;
  173. this.click_order_no = order_no;
  174. this.getLogistics();
  175. },
  176. selectChange(event){
  177. this.select_index = event.detail.value;
  178. console.log("event",event)
  179. },
  180. // 确认发货
  181. confirm(){
  182. if(this.columns[this.select_index] && this.expressNum){
  183. uni.showLoading({
  184. title: '正在提交'
  185. })
  186. let method_id = this.columns[this.select_index].id;
  187. let express_no = this.expressNum;
  188. let order_no = this.click_order_no;
  189. this.$http.get({
  190. api: 'api/supplier/order/send',
  191. data: {
  192. distribution_id: 0,
  193. method_id: method_id,
  194. express_no: express_no,
  195. order_no: order_no
  196. },
  197. header: {
  198. token: this.token
  199. }
  200. }).then(res => {
  201. uni.hideLoading();
  202. this.$msg('发货成功', {icon: 'success'});
  203. this.show_deliver = false;
  204. }).catch(err => uni.hideLoading());
  205. }else{
  206. this.$msg('请将信息补充完整')
  207. }
  208. },
  209. // 删除订单
  210. removeOrder(order_no, parentIndex, childIndex){
  211. uni.showModal({
  212. title: '温馨提示',
  213. content: '确定取消该订单吗?',
  214. success: result => {
  215. if(result.confirm){
  216. this.$http.post({
  217. api: 'api/supplier/order/delete',
  218. data: {
  219. order_no: order_no
  220. },
  221. header: {
  222. token: this.token
  223. }
  224. }).then(res => {
  225. if(res.data.code == 200){
  226. this.$msg(res.data.data);
  227. this.tab_list[parentIndex].list.splice(childIndex, 1);
  228. }
  229. })
  230. }
  231. }
  232. })
  233. },
  234. // scroll-view 滚到底
  235. scrolltolower(){
  236. let tabItem = this.tab_list[this.tab_current];
  237. if(tabItem.isPage){
  238. tabItem.page = tabItem.page+1;
  239. this.getOrderList();
  240. }else{
  241. this.$msg('没有更多啦~')
  242. }
  243. },
  244. // 自定义下拉刷新
  245. refresherrefresh(){
  246. let tabItem = this.tab_list[this.tab_current];
  247. tabItem.isRefresher = true;
  248. tabItem.page = 1;
  249. tabItem.isPage = true;
  250. tabItem.loadingClass = true;
  251. tabItem.loadingText = '正在加载中';
  252. this.getOrderList({refresher: true});
  253. }
  254. }
  255. }
  256. </script>
  257. <style>
  258. page{
  259. background-color: #F8F8F8;
  260. }
  261. </style>
  262. <style lang="scss" scoped="scoped">
  263. .head{
  264. background-color: #FFFFFF;
  265. }
  266. .content{
  267. padding: 30rpx 32rpx;
  268. .card{
  269. width: 686rpx;
  270. height: max-content;
  271. background: #FFFFFF;
  272. border-radius: 20rpx;
  273. padding: 30rpx;
  274. box-sizing: border-box;
  275. &:nth-child(n+2){
  276. margin-top: 20rpx;
  277. }
  278. .shop-name{
  279. font-size: 28rpx;
  280. color: #222222;
  281. font-weight: bold;
  282. margin: 0 15rpx;
  283. }
  284. .goods-img{
  285. width: 130rpx;
  286. height: 130rpx;
  287. border-radius: 5rpx;
  288. margin-right: 15rpx;
  289. background-color: #EEEEEE;
  290. }
  291. .info{
  292. width: 480rpx;
  293. height: 130rpx;
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: space-between;
  297. }
  298. .order-num{
  299. font-size: 24rpx;
  300. color: #555555;
  301. display: flex;
  302. justify-content: space-between;
  303. margin-top: 28rpx;
  304. .deliver{
  305. width: 109rpx;
  306. height: 35rpx;
  307. background: #0E2F9E;
  308. border-radius: 17rpx;
  309. font-size: 24rpx;
  310. color: #FFFFFF;
  311. line-height: 35rpx;
  312. text-align: center;
  313. }
  314. }
  315. }
  316. }
  317. .popup-content{
  318. width: 750rpx;
  319. height: max-content;
  320. background-color: #FFFFFF;
  321. box-sizing: border-box;
  322. padding: 60rpx 32rpx;
  323. .title{
  324. color: #555555;
  325. font-size: 28rpx;
  326. margin-bottom: 30rpx;
  327. }
  328. .logistics{
  329. width: 686rpx;
  330. height: 80rpx;
  331. background: rgba(14, 47, 158, 0.05);
  332. border-radius: 5rpx;
  333. border: 1rpx solid #0E2F9E;
  334. color: #0E2F9E;
  335. font-size: 28rpx;
  336. display: flex;
  337. justify-content: space-between;
  338. align-items: center;
  339. padding: 0 30rpx;
  340. box-sizing: border-box;
  341. margin-bottom: 60rpx;
  342. }
  343. .input{
  344. width: 686rpx;
  345. height: 80rpx;
  346. background: rgba(14, 47, 158, 0.05);
  347. border-radius: 5rpx;
  348. padding: 0 30rpx;
  349. font-size: 28rpx;
  350. margin-bottom: 100rpx;
  351. }
  352. .btn{
  353. width: 550rpx;
  354. height: 100rpx;
  355. background: #0D2E9A;
  356. border-radius: 50rpx;
  357. line-height: 100rpx;
  358. color: #FFFFFF;
  359. }
  360. }
  361. .load-a{
  362. animation: my-load-a 2.5s infinite;
  363. }
  364. @keyframes my-load-a{
  365. 0%{transform: rotate(0deg);}
  366. 25%{transform: rotate(90deg);}
  367. 50%{transform: rotate(180deg);}
  368. 75%{transform: rotate(270deg);}
  369. 100%{transform: rotate(360deg);}
  370. }
  371. // tabs 样式修改
  372. /deep/.u-scroll-box {
  373. display: flex;
  374. justify-content: center;
  375. align-items: center;
  376. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  377. }
  378. /deep/.u-scroll-box .u-tab-bar {
  379. background-color: #0F31A3!important;
  380. width: 80rpx!important;
  381. position: absolute;
  382. left: 0;
  383. bottom: -12rpx;
  384. }
  385. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  386. background-color: #0F31A3!important;
  387. width: 56rpx!important;
  388. position: absolute;
  389. height: 5rpx!important;
  390. left: 8rpx;
  391. bottom: -4rpx;
  392. }
  393. /deep/ .u-tab-item {
  394. font-size: 28rpx!important;
  395. }
  396. </style>