index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. <template>
  2. <view class="page">
  3. <view class="state ">
  4. <view class="flex-row justify-center">
  5. <u-icon name="cut" color="#93D21A" size="18"></u-icon>
  6. <text>{{order.orderStatusDesc}}</text>
  7. </view>
  8. <view class="box_4 flex-row justify-center">
  9. <text>{{order.orderDesc}}</text>
  10. </view>
  11. </view>
  12. <view class="detail">
  13. <view :class="order.serviceAttribute == 1? 'serviceAttrDesc':'serviceAttrDesc1'">
  14. <text>{{order.serviceAttrDesc}}</text>
  15. </view>
  16. <view class="flex-row justify-start orderNo">
  17. <text>订单编号:</text>
  18. <text>{{order.orderNo}}</text>
  19. </view>
  20. <view class="flex-row justify-between jishi">
  21. <view class="flex-col ">
  22. <view class=" flex-row">
  23. <u-icon name="/static/order/ud1.png" color="#93D21A" size="18"></u-icon>
  24. <text class="key">服务日期:</text>
  25. <text class="value">{{order.serviceDate || ''}}</text>
  26. </view>
  27. <view class="flex-row">
  28. <u-icon name="/static/order/ud2.png" color="#93D21A" size="18"></u-icon>
  29. <text class="key">服务门店:</text>
  30. <text class="value">{{order.storeName}}</text>
  31. </view>
  32. <view class="flex-row">
  33. <u-icon name="/static/order/ud14.png" size="16"></u-icon>
  34. <text class="key">下单时间:</text>
  35. <text class="value">{{order.createTime}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="flex-col borderBottom " v-for="(item,index) in order.child" :key="index">
  40. <view class="flex-row justify-between ">
  41. <text class="serviceType">排号:{{item.planNumber || ''}}</text>
  42. <text class="projectState">{{item.statusDesc}}</text>
  43. </view>
  44. <view class="box_11">
  45. <view class="group_2"></view>
  46. <view class="group_3">
  47. <view class="flex-row">
  48. <u-icon name="/static/order/ud22.png" size="16"></u-icon>
  49. <text class="key">服务项目:</text>
  50. <text class="value">{{item.serviceName || ''}}</text>
  51. </view>
  52. <view class="flex-row">
  53. <u-icon name="/static/order/ud21.png" size="16"></u-icon>
  54. <text class="key">服务对象:</text>
  55. <text class="value">{{item.serviceObjectName || ''}}</text>
  56. </view>
  57. <view class="flex-row">
  58. <u-icon name="/static/order/ud14.png" size="16"></u-icon>
  59. <text class="key">服务时段:</text>
  60. <text class="value">{{item.serviceRangeTime || ''}}</text>
  61. </view>
  62. <view class="flex-row">
  63. <u-icon name="/static/order/ud3.png" size="16"></u-icon>
  64. <text class="key">服务人员:</text>
  65. <text class="value">{{item.servicePerson || ''}}</text>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="flex-row justify-between">
  70. <view>
  71. <text class="key">服务金额:</text>
  72. <text class="projectMoney">¥{{item.servicePrice}}</text>
  73. <!-- <text class="lineMoney">¥{{item.servicePrice}}</text>-->
  74. </view>
  75. <view v-if="item.status == 2" class="flex-row" @click="appeal(item.orderServiceId)">
  76. <u-icon name="/static/order/ud17.png" color="#93D21A" size="14"></u-icon>
  77. <text class="ss_key">申诉</text>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="bottomHeight"></view>
  83. <view class="bottom1 flex-col" v-if="canPay">
  84. <text class="allMoney"></text>
  85. <view class="bottomBtn flex-row justify-between">
  86. <view class=" flex-row">
  87. <text class="unpaid">合计</text>
  88. <text class="preferentialPrice">¥{{allPrice}}</text>
  89. <text class="unpaid">已优惠</text>
  90. <text class="originalPrice">¥{{totalDiscount}}</text>
  91. <!-- <text class="priceDetail">价格明细</text>-->
  92. </view>
  93. <view class="btn" @click="qenPayInfo">
  94. <text class="text_33">结 算</text>
  95. </view>
  96. <!-- <view v-else class="btn" @click="orderFinish">-->
  97. <!-- <text class="text_33">结束订单</text>-->
  98. <!-- </view>-->
  99. </view>
  100. </view>
  101. <uni-popup ref="appealPopup" :animation="false" :catchtouchmove="true">
  102. <view class="appealView flex-col justify-around">
  103. <view class="popupTitle">
  104. <text>请输入申诉理由</text>
  105. </view>
  106. <view class="lex-row justify-center">
  107. <textarea class="textarea" v-model="appealReason" placeholder="请输入申诉理由"></textarea>
  108. </view>
  109. <view class="flex-row justify-around">
  110. <view class="leftBtn" @click="appealPopupClose">
  111. <text>取消</text>
  112. </view>
  113. <view class="rightBtn" @click="commitAppeal">
  114. <text>确定</text>
  115. </view>
  116. </view>
  117. </view>
  118. </uni-popup>
  119. <uni-popup ref="popup" :catchtouchmove="true" :animation="false" type="bottom">
  120. <view class="payView">
  121. <view class="flex-row justify-between">
  122. <text class="payType">请选择支付方式</text>
  123. <image class="x" src="/static/common/ox.png" @click="closePayPopup"></image>
  124. </view>
  125. <view class="payTitle">
  126. <text>选择微信支付或余额支付</text>
  127. </view>
  128. <view class="payItem flex-row justify-between" @click="payItem(1)">
  129. <view class="flex-row">
  130. <u-icon name="/static/me/u701.png" color="#38db38" size="36"></u-icon>
  131. <view class="payName flex-col justify-center">
  132. <text>余额支付</text>
  133. <text class="balance">可以余额¥{{userInfo.balance || 0}}</text>
  134. </view>
  135. </view>
  136. <view class="flex-col justify-center">
  137. <view v-if="curServiceTab === 1">
  138. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  139. </view>
  140. <view v-else>
  141. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  142. </view>
  143. </view>
  144. </view>
  145. <view class="payItem flex-row justify-between" @click="payItem(2)">
  146. <view class="flex-row">
  147. <u-icon name="weixin-circle-fill" color="#38db38" size="36"></u-icon>
  148. <view class="payName flex-col justify-center">
  149. <text>微信支付</text>
  150. </view>
  151. </view>
  152. <view class="flex-col justify-center">
  153. <view v-if="curServiceTab === 2">
  154. <u-icon name="checkmark-circle-fill" color="#38db38" size="25"></u-icon>
  155. </view>
  156. <view v-else>
  157. <u-icon name="/static/order/ud9.png" color="green" size="25"></u-icon>
  158. </view>
  159. </view>
  160. </view>
  161. <view class="commitBtn" @click="commonGeneralOrder">
  162. <text>确定</text>
  163. </view>
  164. </view>
  165. </uni-popup>
  166. <uni-popup ref="passwordPopup">
  167. <view class="passwordView flex-col">
  168. <view class="flex-row justify-center">
  169. <text>请输入交易密码</text>
  170. </view>
  171. <view class="h-tab-bar flex-row justify-center">
  172. <u-code-input v-model="password" mode="box" dot></u-code-input>
  173. </view>
  174. <view class="flex-row justify-center">
  175. <view class="h-operate-btn flex-row justify-center" @click="balancePay">
  176. <text>确定</text>
  177. </view>
  178. </view>
  179. </view>
  180. </uni-popup>
  181. </view>
  182. </template>
  183. <script>
  184. import UniPopup from "../../uni_modules/uni-popup/components/uni-popup/uni-popup";
  185. export default {
  186. components: {
  187. UniPopup
  188. },
  189. data() {
  190. return {
  191. title: 'Hello',
  192. tabIndex: 3,
  193. order: {},
  194. allPrice: 0,
  195. totalDiscount: 0,
  196. appealId: '',
  197. appealReason: '',
  198. orderId: '',
  199. curServiceTab: 2,
  200. userInfo: {},
  201. tradeNo: '',
  202. password: '',
  203. requestStatus: false
  204. }
  205. },
  206. onLoad(e) {
  207. this.orderId = e.id
  208. this.getUserInfo();
  209. },
  210. onShow() {
  211. this.getOrderDetailByOrderId(this.orderId)
  212. },
  213. methods: {
  214. getUserInfo() {
  215. this.$api.getUserInfo().then(res => {
  216. this.userInfo = res.data.data
  217. uni.setStorageSync('userInfo', res.data.data);
  218. });
  219. },
  220. balancePay() {
  221. let that = this;
  222. // if(this.password.length< 6 ){
  223. // uni.showToast({
  224. // title: "交易密码不能小于6位"
  225. // })
  226. // return ;
  227. // }
  228. // this.$refs.passwordPopup.close()
  229. this.$api.trade({
  230. tradeNo: this.tradeNo,
  231. password: ''
  232. }).then((res) => {
  233. this.requestStatus = false
  234. uni.hideLoading();
  235. uni.showToast({
  236. title: '支付成功!'
  237. });
  238. that.$refs.popup.close()
  239. that.getOrderDetailByOrderId(that.orderId)
  240. }).catch((err) => {
  241. this.requestStatus = false
  242. uni.hideLoading();
  243. uni.showToast({
  244. title: err.msg,
  245. icon: 'error'
  246. })
  247. })
  248. },
  249. scanCodeOrder(order) {
  250. uni.scanCode({
  251. scanType: ['qrCode'],
  252. success: function(res) {
  253. let json = JSON.parse(res.result)
  254. if (json.storeId != order.storeId) {
  255. uni.showToast({
  256. icon: 'error',
  257. duration: 3000,
  258. title: '请扫描订单门店二维码'
  259. });
  260. return
  261. }
  262. uni.navigateTo({
  263. url: '/orderPages/serviceItems/index?serviceStationId=' + json.stationId +
  264. '&orderId=' + order.orderId + '&serviceObjectId=' + order
  265. .serviceObjectId
  266. })
  267. }
  268. })
  269. },
  270. commonGeneralOrder() {
  271. if (this.requestStatus) {
  272. return;
  273. }
  274. this.requestStatus = true
  275. uni.showLoading({
  276. title: '支付中'
  277. });
  278. let that = this
  279. if (this.curServiceTab === 1) {
  280. // that.password = '';
  281. // this.$refs.popup.close()
  282. // this.$refs.passwordPopup.open()
  283. this.balancePay()
  284. } else {
  285. this.$api.wechatPayTradeNo({
  286. tradeNo: this.tradeNo
  287. }).then(res => {
  288. var param = res.data.data;
  289. uni.requestPayment({
  290. appId: param.appid,
  291. timeStamp: param.timestamp + "",
  292. nonceStr: param.noncestr,
  293. package: "prepay_id=" + param.prepayid,
  294. signType: "RSA",
  295. paySign: param.sign,
  296. success: res => {
  297. this.requestStatus = false
  298. uni.hideLoading();
  299. uni.showToast({
  300. title: '支付成功!'
  301. });
  302. that.getOrderDetailByOrderId(that.orderId)
  303. that.$refs.popup.close()
  304. },
  305. fail: res => {
  306. this.requestStatus = false
  307. uni.hideLoading();
  308. uni.showModal({
  309. content: '支付失败',
  310. showCancel: false
  311. });
  312. that.$refs.popup.close()
  313. }
  314. });
  315. })
  316. }
  317. },
  318. orderFinish() {
  319. this.$api.orderFinish(this.order.orderNo).then((res) => {
  320. uni.$u.toast('操作成功')
  321. this.getOrderDetailByOrderId(this.order.orderId)
  322. })
  323. },
  324. qenPayInfo() {
  325. for (let i = 0; i < this.order.child.length; i++) {
  326. if (this.order.child[i].status == 3) {
  327. uni.$u.toast('子订单未审核结束')
  328. return
  329. }
  330. }
  331. this.getUserInfo();
  332. let orderServiceIds = []
  333. this.order.child.forEach(i => {
  334. if (i.status != 5) { //排除审核通过的子订单
  335. orderServiceIds.push(i.orderServiceId)
  336. }
  337. })
  338. this.$api.qenPayInfo({
  339. orderServiceIds: orderServiceIds,
  340. orderNo: this.order.orderNo
  341. }).then(res => {
  342. this.tradeNo = res.data.data.tradeNo
  343. this.$refs.popup.open()
  344. })
  345. },
  346. commitAppeal() {
  347. this.$api.appeal({
  348. childOrderId: this.appealId,
  349. appealReason: this.appealReason
  350. }).then(res => {
  351. this.appealReason = ''
  352. uni.$u.toast('申诉已提交')
  353. this.$refs.appealPopup.close()
  354. this.getOrderDetailByOrderId(this.orderId)
  355. })
  356. },
  357. appealPopupClose() {
  358. this.appealReason = ''
  359. this.$refs.appealPopup.close()
  360. },
  361. appeal(id) {
  362. this.appealId = id
  363. this.$refs.appealPopup.open()
  364. },
  365. // 原来的计算价格逻辑 选择的时候计算
  366. // tick(item,index){
  367. //
  368. // if (item.status === 1 || item.status === 4){
  369. // this.allPrice = 0
  370. // this.totalDiscount = 0;
  371. // item.tick = !item.tick
  372. // this.$set(this.order.child,index,item)
  373. // this.order.child.forEach(i=>{
  374. // if (i.tick){
  375. // this.totalDiscount += i.discountAmount * 1;
  376. // this.allPrice += i.payAmount *1;
  377. // }
  378. // })
  379. // this.allPrice = this.allPrice.toFixed(2)
  380. // this.totalDiscount = this.totalDiscount.toFixed(2)
  381. // }
  382. // },
  383. //新的价格计算逻辑 订单加载或刷新的时候计算
  384. calculatePrice() {
  385. this.allPrice = 0
  386. this.totalDiscount = 0;
  387. this.order.child.forEach(i => {
  388. if (i.status != 5) { //不在申诉的子订单
  389. this.totalDiscount += i.discountAmount * 1;
  390. this.allPrice += i.payAmount * 1;
  391. }
  392. })
  393. this.allPrice = this.allPrice.toFixed(2)
  394. this.totalDiscount = this.totalDiscount.toFixed(2)
  395. },
  396. getOrderDetailByOrderId(id) {
  397. this.$api.getOrderDetailByOrderId({
  398. id: id
  399. }).then(res => {
  400. this.order = res.data.data
  401. this.calculatePrice()
  402. })
  403. },
  404. payItem(num) {
  405. console.log('this.userInfo.balance', this.userInfo.balance * 1)
  406. console.log('this.price', this.allPrice * 1)
  407. if (this.userInfo.balance * 1 < this.allPrice * 1 && num == 1) {
  408. return
  409. }
  410. this.curServiceTab = num
  411. },
  412. closePayPopup() {
  413. this.$refs.popup.close()
  414. },
  415. }
  416. }
  417. </script>
  418. <style>
  419. @import '/common/css/common.css';
  420. @import './index.rpx.scss';
  421. </style>