order.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <view class="container">
  3. <picker @change="bindPickerChange" v-model="index" :range="array" :range-key="'name'">
  4. <view class="picker">
  5. <view class="label">状态</view>
  6. <view class="fb-type">
  7. <view class="type-label">{{array[index].name}}</view>
  8. <image class="type-icon"
  9. src="/static/images/icon_select.png">
  10. </image>
  11. </view>
  12. </view>
  13. </picker>
  14. <picker @change="bindPickerChange2" v-model="index2" :range="deviceList" :range-key="'name'">
  15. <view class="picker" style="position: relative;">
  16. <view class="label">设备</view>
  17. <view class="fb-type">
  18. <view class="type-label">{{deviceList[index2].name}}</view>
  19. <image class="type-icon"
  20. src="/static/images/icon_select.png">
  21. </image>
  22. </view>
  23. </view>
  24. </picker>
  25. <view class="picker" style="position: relative;">
  26. <view class="label" v-if="isToday">今日订单</view>
  27. <view class="fb-type">
  28. <text>{{range[0]?range[0]:''}} - {{range[1]?range[1]:''}}</text>
  29. <button type="primary" @click="onShowDatePicker('range')" :disabled="isToday" >选择</button>
  30. </view>
  31. </view>
  32. <mx-date-picker :show="showPicker" :type="type" :value="value" :show-tips="true" :begin-text="'开始'"           
  33.  :end-text="'结束'" :show-seconds="true" @confirm="onSelected" @cancel="onCancel" />
  34. <view class="statistics">
  35. <view class="cell">
  36. <text class="val">{{orderCount}}</text>
  37. <text class="txt">订单总数</text>
  38. </view>
  39. <view class="cell">
  40. <text class="val">{{orderSum}}</text>
  41. <text class="txt">订单销售总金额</text>
  42. </view>
  43. </view>
  44. <view class="orders" v-if="orderList.length>0">
  45. <navigator :url="'../order/orderDetail?id='+item.id" class="order" v-for="(item, index) in orderList"
  46. :key="item.id">
  47. <view class="h">
  48. <view class="l">创建时间:{{item.createTime||''}}</view>
  49. <view class="r">{{array[parseInt(item.orderStatus)+1].name}}</view>
  50. </view>
  51. <view class="h">
  52. <view class="l">订单编号:{{item.id||''}}</view>
  53. <view class="r">¥{{item.orderAmount||'0'}}</view>
  54. </view>
  55. <view class="h">
  56. <view class="l">会员名称:{{item.orderMemberName||''}}</view>
  57. </view>
  58. <view class="h">
  59. <view class="l">设备名称:{{item.deviceName||''}}</view>
  60. </view>
  61. <view class="h">
  62. <view class="l">产品名称:{{item.orderGoodsName||''}}</view>
  63. </view>
  64. <view class="h" v-if="item.errorMsg && item.orderStatus==2">
  65. <view class="l">异常原因:{{item.errorMsg}}</view>
  66. </view>
  67. <view class="b" v-if="false">
  68. <view class="l"></view>
  69. <view class="r">
  70. <button class="btn" :data-order-index="index" @click.stop.prevent="payOrder">立即支付</button>
  71. </view>
  72. </view>
  73. </navigator>
  74. </view>
  75. <tui-show-empty v-else text="暂无订单"></tui-show-empty>
  76. </view>
  77. </template>
  78. <script>
  79. import MxDatePicker from "@/components/mx-datepicker/mx-datepicker.vue";
  80. const util = require("@/utils/util.js");
  81. const api = require('@/utils/api.js');
  82. export default {
  83. data() {
  84. return {
  85. range: [],
  86. value: '',
  87. type: '',
  88. showPicker: false,
  89. index: 0,
  90. index2: 0,
  91. isToday: true,
  92. //statusId: '0',
  93. //deviceId: '',
  94. deviceList: [{
  95. id: '',
  96. name: '全部'
  97. }],
  98. orderCount: 2,
  99. orderSum: 0.0,
  100. array: [{
  101. id: "",
  102. name: '全部'
  103. },{id:"0", name: '未支付'},{id:"1", name: '已支付'},{id:"2", name:'已取消'},{id:"3", name:'生产完成'},{id:"4", name: '异常'},{id:"5", name: '转入退款'},],
  104. orderList: [
  105. /*{
  106. name: '美式咖啡',
  107. memberName: '飞起来的虫',
  108. orderSn: 'DD202106010',
  109. deviceName: '果奶机02',
  110. createTime: '2021-07-04 12:13',
  111. status: '1',
  112. price: '15.2',
  113. errorMsg: '生产中断'
  114. }, {
  115. name: '美式咖啡',
  116. memberName: '飞起来的虫',
  117. orderSn: 'DD202106020',
  118. deviceName: '果奶机01',
  119. createTime: '2021-08-06 16:25',
  120. status: '2',
  121. price: '15.0',
  122. errorMsg: '生产失败'
  123. }, {
  124. name: '美式咖啡',
  125. memberName: '飞起来的虫',
  126. orderSn: 'DD202106030',
  127. deviceName: '果奶机03',
  128. createTime: '2021-10-14 19:25',
  129. status: '3',
  130. price: '15.0',
  131. errorMsg: ''
  132. }*/
  133. ],
  134. queryParams: util.initQueryParams(),
  135. totalPages: 1,
  136. totalPages2: 1
  137. }
  138. },
  139. components: {
  140. MxDatePicker
  141. },
  142. methods: {
  143. bindPickerChange: function(e) {
  144. this.index = e.detail.value
  145. //this.statusId = this.array[this.index].id
  146. this.orderList = []
  147. this.queryParams.current = 1
  148. let pages = getCurrentPages();
  149. let page = pages[pages.length - 1].$page.fullPath;
  150. let oType = page.split('type=')[1]
  151. this.getOrderList(oType)
  152. },
  153. bindPickerChange2: function(e) {
  154. this.index2 = e.detail.value;
  155. //this.deviceId = this.deviceList[this.index2].id
  156. this.orderList = []
  157. this.queryParams.current = 1
  158. //this.queryParams.model.orderEquId = this.deviceId
  159. let pages = getCurrentPages();
  160. let page = pages[pages.length - 1].$page.fullPath;
  161. let oType = page.split('type=')[1]
  162. this.getOrderList(oType)
  163. },
  164. bindDateChange: function(e) {
  165. this.date = e.detail.value
  166. },
  167. onShowDatePicker(type) { //显示
  168. console.log(JSON.stringify(type))
  169. this.type = type;
  170. this.showPicker = true;
  171. this.value = this[type];
  172. },
  173. onSelected(e) { //选择
  174. console.log(JSON.stringify(e))
  175. this.showPicker = false;
  176. if (e) {
  177. this[this.type] = e.value;
  178. }
  179. this.orderList = []
  180. this.queryParams.current = 1
  181. let pages = getCurrentPages();
  182. let page = pages[pages.length - 1].$page.fullPath;
  183. let oType = page.split('type=')[1]
  184. console.log(oType)
  185. this.getOrderList(oType)
  186. },
  187. onCancel(e) {
  188. this.range = []
  189. this.showPicker = false;
  190. if (e) {
  191. this[this.type] = '';
  192. }
  193. this.orderList = []
  194. this.queryParams.current = 1
  195. let pages = getCurrentPages();
  196. let page = pages[pages.length - 1].$page.fullPath;
  197. let oType = page.split('type=')[1]
  198. this.getOrderList(oType)
  199. },
  200. getDeviceList(equId) {
  201. let that = this;
  202. util.request(api.DeviceList, {}, 'post', 'application/json').then(function(res) {
  203. if (res.code === 0) {
  204. //that.orderList = that.orderList.concat(res.data.data)
  205. //that.page = res.data.currentPage + 1
  206. that.totalPages2 = res.pages
  207. that.deviceList = that.deviceList.concat(res.data.records)
  208. if(equId){
  209. that.deviceId = equId;
  210. that.index2 = that.deviceList.findIndex(function(item){
  211. return item.id === equId;
  212. });
  213. }
  214. }
  215. });
  216. },
  217. getOrderList(type) {
  218. let that = this;
  219. if(type=="1"){
  220. that.range=[util.getNowDate(0), util.getNowDate(1)];
  221. that.isToday = true
  222. }else{
  223. if(type=="2"){
  224. that.index = 5
  225. }
  226. that.isToday = false
  227. }
  228. if (that.index2) {
  229. that.queryParams.model.orderEquId = that.deviceList[that.index2].id
  230. }
  231. if(that.index){
  232. that.queryParams.model.orderStatus = that.array[that.index].id
  233. }else if(that.index==''){
  234. that.queryParams.model.orderStatus =''
  235. }
  236. console.log(that.range)
  237. if (that.range.length > 0) {
  238. that.queryParams.map.createTime_st = that.range[0];
  239. that.queryParams.map.createTime_ed = that.range[1];
  240. }
  241. util.request(api.OrderList, that.queryParams, 'post', 'application/json').then(function(res) {
  242. if (res.code === 0) {
  243. res.data.records = res.data.records.filter(item=>{
  244. if(item.id==null){
  245. that.orderSum = item.orderSum;
  246. return false
  247. }
  248. return true;
  249. })
  250. that.orderList = that.orderList.concat(res.data.records);
  251. //that.page = res.data.currentPage + 1
  252. that.totalPages = res.data.pages
  253. that.orderCount = res.data.total
  254. }
  255. });
  256. },
  257. payOrder(event) {
  258. let that = this;
  259. let orderIndex = event.currentTarget.dataset.orderIndex;
  260. let order = that.orderList[orderIndex];
  261. util.payOrder(parseInt(order.id)).then(res => {
  262. that.getOrderList();
  263. }).catch(res => {
  264. util.toast('支付失败');
  265. });
  266. }
  267. },
  268. /**
  269. * 页面上拉触底事件的处理函数
  270. */
  271. onReachBottom: function() {
  272. let pages = getCurrentPages();
  273. let page = pages[pages.length - 1].$page.fullPath;
  274. let type = page.split('type=')[1]
  275. type = type? type: ""
  276. if (this.totalPages > this.queryParams.current) {
  277. this.queryParams.current = this.queryParams.current + 1
  278. } else {
  279. return false;
  280. }
  281. this.getOrderList(type)
  282. },
  283. onLoad: function(option) {
  284. let type = option.type? option.type : ""
  285. let equId = option.equId? option.equId : ""
  286. this.getDeviceList(equId);
  287. this.getOrderList(type);
  288. }
  289. }
  290. </script>
  291. <style lang="scss">
  292. page {
  293. height: 100%;
  294. width: 100%;
  295. background: #f4f4f4;
  296. }
  297. .orders {
  298. height: auto;
  299. width: 100%;
  300. overflow: hidden;
  301. }
  302. .order {
  303. margin-top: 20rpx;
  304. background: #fff;
  305. }
  306. .order .h {
  307. height: 83.3rpx;
  308. line-height: 83.3rpx;
  309. margin-left: 31.25rpx;
  310. padding-right: 31.25rpx;
  311. border-bottom: 1px solid #f4f4f4;
  312. font-size: 30rpx;
  313. color: #333;
  314. }
  315. .order .h .l {
  316. float: left;
  317. }
  318. .order .h .r {
  319. float: right;
  320. color: #b4282d;
  321. font-size: 24rpx;
  322. }
  323. .order .goods {
  324. display: flex;
  325. align-items: center;
  326. height: 199rpx;
  327. margin-left: 31.25rpx;
  328. }
  329. .order .goods .img {
  330. height: 145.83rpx;
  331. width: 145.83rpx;
  332. background: #f4f4f4;
  333. }
  334. .order .goods .img image {
  335. height: 145.83rpx;
  336. width: 145.83rpx;
  337. }
  338. .order .goods .info {
  339. height: 145.83rpx;
  340. flex: 1;
  341. padding-left: 20rpx;
  342. }
  343. .order .goods .name {
  344. margin-top: 30rpx;
  345. display: block;
  346. height: 44rpx;
  347. line-height: 44rpx;
  348. color: #333;
  349. font-size: 30rpx;
  350. }
  351. .order .goods .number {
  352. display: block;
  353. height: 37rpx;
  354. line-height: 37rpx;
  355. color: #666;
  356. font-size: 25rpx;
  357. }
  358. .order .goods .status {
  359. width: 105rpx;
  360. color: #b4282d;
  361. font-size: 25rpx;
  362. }
  363. .order .b {
  364. height: 103rpx;
  365. line-height: 103rpx;
  366. margin-left: 31.25rpx;
  367. padding-right: 31.25rpx;
  368. border-top: 1px solid #f4f4f4;
  369. font-size: 30rpx;
  370. color: #333;
  371. }
  372. .order .b .l {
  373. float: left;
  374. }
  375. .order .b .r {
  376. float: right;
  377. }
  378. .order .b .btn {
  379. margin-top: 19rpx;
  380. height: 64.5rpx;
  381. line-height: 64.5rpx;
  382. text-align: center;
  383. padding: 0 20rpx;
  384. border-radius: 5rpx;
  385. font-size: 26rpx;
  386. color: #fff;
  387. background: #b4282d;
  388. }
  389. .statistics {
  390. display: flex;
  391. height: 200rpx;
  392. width: 100%;
  393. flex-flow: row wrap;
  394. align-items: center;
  395. justify-content: space-between;
  396. background-color: #fff;
  397. margin: 50rpx 0;
  398. box-sizing: border-box;
  399. }
  400. .statistics .cell {
  401. width: 48%;
  402. text-align: center;
  403. display: block;
  404. vertical-align: middle;
  405. }
  406. .statistics .cell .val {
  407. font-size: 50rpx;
  408. padding: 40rpx;
  409. margin-left: 32%;
  410. }
  411. .statistics .cell .txt {
  412. font-size: 30rpx;
  413. padding: 40rpx 0;
  414. margin-left: 32%;
  415. }
  416. .fb-type {
  417. height: 104rpx;
  418. width: 80%;
  419. margin-left: 20%;
  420. background: #fff;
  421. margin-bottom: 20rpx;
  422. display: flex;
  423. flex-direction: row;
  424. align-items: center;
  425. padding-left: 30rpx;
  426. padding-right: 30rpx;
  427. }
  428. .fb-type .type-label {
  429. height: 36rpx;
  430. flex: 1;
  431. color: #333;
  432. font-size: 28rpx;
  433. }
  434. .fb-type .type-icon {
  435. height: 36rpx;
  436. width: 36rpx;
  437. }
  438. .label {
  439. position: absolute;
  440. top: 27rpx;
  441. left: 30rpx;
  442. height: 50rpx;
  443. width: 100%;
  444. color: #333;
  445. line-height: 50rpx;
  446. font-size: 28rpx;
  447. }
  448. </style>