金诚优选前端代码
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.

404 lines
10 KiB

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