小程序端工程代码
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.

388 lines
11 KiB

  1. <template>
  2. <view class="pos-order-list" ref="container">
  3. <view class="nav acea-row row-around row-middle">
  4. <view class="item" :class="where.status == 0 ? 'on' : ''" @click="changeStatus(0)">待付款</view>
  5. <view class="item" :class="where.status == 1 ? 'on' : ''" @click="changeStatus(1)">待发货</view>
  6. <view class="item" :class="where.status == 2 ? 'on' : ''" @click="changeStatus(2)">待收货</view>
  7. <view class="item" :class="where.status == 3 ? 'on' : ''" @click="changeStatus(3)">待评价</view>
  8. <view class="item" :class="where.status == 4 ? 'on' : ''" @click="changeStatus(4)">已完成</view>
  9. <view class="item" :class="where.status == -3 ? 'on' : ''" @click="changeStatus(-3)">退款</view>
  10. </view>
  11. <view class="list">
  12. <view class="item" v-for="(item, listIndex) in list" :key="listIndex">
  13. <view class="order-num acea-row row-middle" @click="toDetail(item)">
  14. <text>订单号{{ item.orderId }}</text>
  15. <text class="time acea-row row-between">
  16. <text>下单时间</text>
  17. <text class="conter">{{ item.createTime }}</text>
  18. </text>
  19. </view>
  20. <view class="pos-order-goods" v-for="(val, key) in item.cartInfo" :key="key">
  21. <view class="goods acea-row row-between-wrapper" @click="toDetail(item)">
  22. <view class="picTxt acea-row row-between-wrapper">
  23. <view class="pictrue">
  24. <image :src="val.productInfo.image" />
  25. </view>
  26. <view class="text acea-row row-between row-column">
  27. <view class="info line2">{{ val.productInfo.storeName }}</view>
  28. <view class="attr" v-if="val.productInfo.sku">{{ val.productInfo.sku }}</view>
  29. </view>
  30. </view>
  31. <view class="money">
  32. <view class="x-money">{{ val.productInfo.price }}</view>
  33. <view class="num">x{{ val.cartNum }}</view>
  34. <view class="y-money" v-if="val.productInfo.otPrice">{{ val.productInfo.otPrice }}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="public-total">
  39. {{ item.totalNum }}件商品应支付
  40. <text class="money">{{ item.payPrice }}</text>
  41. ( 邮费 ¥{{item.totalPostage}})
  42. </view>
  43. <view class="operation acea-row row-between-wrapper">
  44. <view class="more">
  45. <!-- <view class="iconfont icon-gengduo" @click="more(index)"></view>-->
  46. <!-- <view class="order" v-show="current === index">-->
  47. <!-- <view class="items">-->
  48. <!-- {{ where.status > 0 ? "删除" : "取消" }}订单-->
  49. <!-- </view>-->
  50. <!-- <view class="arrow"></view>-->
  51. <!-- </view>-->
  52. </view>
  53. <view class="acea-row row-middle">
  54. <view class="bnt" @click="modify(item, 0)" v-if="where.status == 0">一键改价</view>
  55. <view class="bnt" @click="modify(item, 0)" v-if="where.status == -3 && item.refundStatus === 1">立即退款</view>
  56. <view class="bnt cancel" v-if="item.pay_type === 'offline' && item.paid === 0" @click="offlinePay(item)">确认付款</view>
  57. <view class="bnt" v-if="where.status == 1 && item._status._title=='未发货'" @click="goGoodsDeliver(item)">去发货</view>
  58. <view class="bnt cancel" v-if="item._status._title=='待核销' && where.status == 1" @click="storeCancellation(0,item.verifyCode)">快速核销</view>
  59. <view class="bnt" v-if="item._status._title=='待核销' && where.status == 1" @click="storeCancellation(1,item.verifyCode)">立即核销</view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <Loading :loaded="loaded" :loading="loading"></Loading>
  65. <PriceChange
  66. :change="change"
  67. :orderInfo="orderInfo"
  68. v-on:closechange="changeclose($event)"
  69. v-on:savePrice="savePrice"
  70. :status="status"></PriceChange>
  71. </view>
  72. </template>
  73. <script>
  74. import PriceChange from "@/components/PriceChange";
  75. import Loading from "@/components/Loading";
  76. import DataFormat from "@/components/DataFormat";
  77. import {
  78. getAdminOrderList,
  79. setAdminOrderPrice,
  80. setAdminOrderRemark,
  81. setOfflinePay,
  82. setOrderRefund
  83. } from "@/api/admin";
  84. import {orderVerific} from "@/api/order";
  85. import {
  86. required,
  87. num
  88. } from "@/utils/validate";
  89. import {
  90. validatorDefaultCatch
  91. } from "@/utils/dialog";
  92. export default {
  93. name: "AdminOrderList",
  94. components: {
  95. PriceChange,
  96. Loading,
  97. DataFormat
  98. },
  99. props: {},
  100. data: function() {
  101. return {
  102. current: "",
  103. change: false,
  104. types: 0,
  105. where: {
  106. page: 1,
  107. limit: 5,
  108. status: 0
  109. },
  110. list: [],
  111. loaded: false,
  112. loading: false,
  113. orderInfo: {},
  114. status: ""
  115. };
  116. },
  117. watch: {
  118. "$yroute.query.types": function(newVal) {
  119. let that = this;
  120. if (newVal != undefined) {
  121. that.where.status = newVal;
  122. that.init();
  123. }
  124. },
  125. types: function() {
  126. this.getIndex();
  127. }
  128. },
  129. onShow: function() {
  130. let that = this;
  131. that.where.status = that.$yroute.query.types;
  132. that.current = "";
  133. that.getIndex();
  134. },
  135. onReachBottom() {
  136. !this.loading && this.getIndex();
  137. },
  138. methods: {
  139. goGoodsDeliver(item) {
  140. this.$yrouter.push({
  141. path: "/pages/orderAdmin/GoodsDeliver/index",
  142. query: {
  143. oid: item.orderId
  144. }
  145. });
  146. },
  147. more: function(index) {
  148. if (this.current === index) this.current = "";
  149. else this.current = index;
  150. },
  151. modify: function(item, status) {
  152. this.change = true;
  153. this.orderInfo = item;
  154. this.status = status;
  155. },
  156. changeclose: function(msg) {
  157. this.change = msg;
  158. },
  159. async savePrice(opt) {
  160. let that = this,
  161. data = {},
  162. price = opt.price.toString(),
  163. refund_price = opt.refund_price.toString(),
  164. refund_status = that.orderInfo.refundStatus,
  165. remark = opt.remark;
  166. data.orderId = that.orderInfo.orderId;
  167. if (that.status == 0 && refund_status === 0) {
  168. try {
  169. await this.$validator({
  170. price: [
  171. required(required.message("金额")),
  172. num(num.message("金额"))
  173. ]
  174. }).validate({
  175. price
  176. });
  177. } catch (e) {
  178. return validatorDefaultCatch(e);
  179. }
  180. data.price = price;
  181. setAdminOrderPrice(data).then(
  182. function() {
  183. that.change = false;
  184. uni.showToast({
  185. title: "改价成功",
  186. icon: "success",
  187. duration: 2000
  188. });
  189. that.init();
  190. },
  191. function() {
  192. that.change = false;
  193. uni.showToast({
  194. title: "改价失败",
  195. icon: "none",
  196. duration: 2000
  197. });
  198. }
  199. );
  200. } else if (that.status == 0 && refund_status === 1) {
  201. try {
  202. await this.$validator({
  203. refund_price: [
  204. required(required.message("金额")),
  205. num(num.message("金额"))
  206. ]
  207. }).validate({
  208. refund_price
  209. });
  210. } catch (e) {
  211. return validatorDefaultCatch(e);
  212. }
  213. data.price = refund_price;
  214. data.type = opt.type;
  215. setOrderRefund(data).then(
  216. res => {
  217. that.change = false;
  218. uni.showToast({
  219. title: res.msg,
  220. icon: "none",
  221. duration: 2000
  222. });
  223. that.init();
  224. },
  225. err => {
  226. that.change = false;
  227. uni.showToast({
  228. title: res.msg,
  229. icon: "none",
  230. duration: 2000
  231. });
  232. }
  233. );
  234. } else {
  235. try {
  236. await this.$validator({
  237. remark: [required(required.message("备注"))]
  238. }).validate({
  239. remark
  240. });
  241. } catch (e) {
  242. return validatorDefaultCatch(e);
  243. }
  244. data.remark = remark;
  245. setAdminOrderRemark(data).then(
  246. res => {
  247. that.change = false;
  248. uni.showToast({
  249. title: res.msg,
  250. icon: "none",
  251. duration: 2000
  252. });
  253. that.init();
  254. },
  255. err => {
  256. that.change = false;
  257. uni.showToast({
  258. title: res.msg,
  259. icon: "none",
  260. duration: 2000
  261. });
  262. }
  263. );
  264. }
  265. },
  266. init: function() {
  267. this.list = [];
  268. this.where.page = 1;
  269. this.loaded = false;
  270. this.loading = false;
  271. this.getIndex();
  272. this.current = "";
  273. },
  274. getIndex: function() {
  275. let that = this;
  276. if (that.loading || that.loaded) return;
  277. that.loading = true;
  278. getAdminOrderList(that.where).then(
  279. res => {
  280. that.loading = false;
  281. that.loaded = res.data.length < that.where.limit;
  282. that.list.push.apply(that.list, res.data);
  283. that.where.page = that.where.page + 1;
  284. },
  285. err => {
  286. uni.showToast({
  287. title: res.msg,
  288. icon: "none",
  289. duration: 2000
  290. });
  291. }
  292. );
  293. },
  294. changeStatus: function(val) {
  295. if (this.where.status != val) {
  296. this.where.status = val;
  297. this.init();
  298. }
  299. },
  300. toDetail: function(item) {
  301. this.$yrouter.push({
  302. path: "/pages/orderAdmin/AdminOrder/index",
  303. query: {
  304. oid: item.orderId
  305. }
  306. });
  307. },
  308. offlinePay: function(item) {
  309. setOfflinePay({
  310. order_id: item.order_id
  311. }).then(
  312. res => {
  313. uni.showToast({
  314. title: res.msg,
  315. icon: "none",
  316. duration: 2000
  317. });
  318. this.init();
  319. },
  320. error => {
  321. uni.showToast({
  322. title: error.msg,
  323. icon: 'none',
  324. duration: 2000
  325. });
  326. }
  327. );
  328. },
  329. storeCancellation(index,verifyCode) {
  330. const that = this;
  331. that.check = true;
  332. if (index == 0) {
  333. uni.showModal({
  334. title: "确定核销订单?",
  335. content: "注意:请务必核对核销码的与客户正确性",
  336. success(res) {
  337. if (res.confirm) {
  338. uni.showLoading({
  339. title: "查询中"
  340. });
  341. orderVerific(verifyCode, 1)
  342. .then(res => {
  343. console.log(res)
  344. uni.hideLoading();
  345. that.iShidden = false;
  346. uni.showToast({
  347. title: res.msg,
  348. icon: 'none',
  349. duration: 1000
  350. });
  351. //最后就是返回上一个页面。
  352. setTimeout(function() {
  353. uni.navigateBack({
  354. delta: 1, // 返回上一级页面。
  355. success: function() {
  356. console.log('成功!')
  357. }
  358. })
  359. }, 1000);
  360. })
  361. .catch((err) => {
  362. console.log(err)
  363. uni.hideLoading();
  364. uni.showToast({
  365. title: err.data.msg,
  366. icon: "none",
  367. duration: 2000
  368. });
  369. });
  370. }
  371. }
  372. });
  373. } else {
  374. that.$yrouter.push({
  375. path: '/pages/orderAdmin/OrderCancellation/index'
  376. })
  377. }
  378. }
  379. }
  380. };
  381. </script>
  382. <style lang="less">
  383. .quick {
  384. background: #F25555;
  385. }
  386. </style>