index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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">排号:A102</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.servicePerson || ''}}</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.servicePerson || ''}}</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.servicePerson || ''}}</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.payAmount}}</text>
  73. <!-- <text class="lineMoney">¥{{item.servicePrice}}</text>-->
  74. </view>
  75. <view 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" >
  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 v-if="order.canPay" 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 + '&orderId='+order.orderId + '&serviceObjectId=' + order.serviceObjectId
  264. })
  265. }
  266. })
  267. },
  268. commonGeneralOrder(){
  269. if(this.requestStatus){
  270. return;
  271. }
  272. this.requestStatus=true
  273. uni.showLoading({
  274. title: '支付中'
  275. });
  276. let that =this
  277. if (this.curServiceTab===1){
  278. // that.password = '';
  279. // this.$refs.popup.close()
  280. // this.$refs.passwordPopup.open()
  281. this.balancePay()
  282. }else {
  283. this.$api.wechatPayTradeNo({tradeNo:this.tradeNo}).then(res=>{
  284. var param = res.data.data;
  285. uni.requestPayment({
  286. appId: param.appid,
  287. timeStamp: param.timestamp+"",
  288. nonceStr: param.noncestr,
  289. package: "prepay_id="+param.prepayid,
  290. signType: "RSA",
  291. paySign: param.sign,
  292. success: res => {
  293. this.requestStatus=false
  294. uni.hideLoading();
  295. uni.showToast({
  296. title: '支付成功!'
  297. });
  298. that.getOrderDetailByOrderId(that.orderId)
  299. that.$refs.popup.close()
  300. },
  301. fail: res => {
  302. this.requestStatus=false
  303. uni.hideLoading();
  304. uni.showModal({
  305. content: '支付失败',
  306. showCancel: false
  307. });
  308. that.$refs.popup.close()
  309. }
  310. });
  311. })
  312. }
  313. },
  314. orderFinish(){
  315. this.$api.orderFinish(this.order.orderNo).then((res)=>{
  316. uni.$u.toast('操作成功')
  317. this.getOrderDetailByOrderId(this.order.orderId)
  318. })
  319. },
  320. qenPayInfo(){
  321. for(let i=0;i<this.order.child.length;i++){
  322. if (this.order.child[i].status==3){
  323. uni.$u.toast('子订单未审核结束')
  324. return
  325. }
  326. }
  327. this.getUserInfo();
  328. let orderServiceIds = []
  329. this.order.child.forEach(i=>{
  330. if (i.status !=5){ //排除审核通过的子订单
  331. orderServiceIds.push(i.orderServiceId)
  332. }
  333. })
  334. this.$api.qenPayInfo({
  335. orderServiceIds:orderServiceIds,
  336. orderNo:this.order.orderNo
  337. }).then(res=>{
  338. this.tradeNo=res.data.data.tradeNo
  339. this.$refs.popup.open()
  340. })
  341. },
  342. commitAppeal(){
  343. this.$api.appeal({
  344. childOrderId:this.appealId,
  345. appealReason:this.appealReason
  346. }).then(res=>{
  347. this.appealReason=''
  348. uni.$u.toast('申诉已提交')
  349. this.$refs.appealPopup.close()
  350. this.getOrderDetailByOrderId(this.orderId)
  351. })
  352. },
  353. appealPopupClose(){
  354. this.appealReason=''
  355. this.$refs.appealPopup.close()
  356. },
  357. appeal(id){
  358. this.appealId = id
  359. this.$refs.appealPopup.open()
  360. },
  361. // 原来的计算价格逻辑 选择的时候计算
  362. // tick(item,index){
  363. //
  364. // if (item.status === 1 || item.status === 4){
  365. // this.allPrice = 0
  366. // this.totalDiscount = 0;
  367. // item.tick = !item.tick
  368. // this.$set(this.order.child,index,item)
  369. // this.order.child.forEach(i=>{
  370. // if (i.tick){
  371. // this.totalDiscount += i.discountAmount * 1;
  372. // this.allPrice += i.payAmount *1;
  373. // }
  374. // })
  375. // this.allPrice = this.allPrice.toFixed(2)
  376. // this.totalDiscount = this.totalDiscount.toFixed(2)
  377. // }
  378. // },
  379. //新的价格计算逻辑 订单加载或刷新的时候计算
  380. calculatePrice(){
  381. this.allPrice = 0
  382. this.totalDiscount = 0;
  383. this.order.child.forEach(i=>{
  384. if (i.status !=5){ //不在申诉的子订单
  385. this.totalDiscount += i.discountAmount * 1;
  386. this.allPrice += i.payAmount *1;
  387. }
  388. })
  389. this.allPrice = this.allPrice.toFixed(2)
  390. this.totalDiscount = this.totalDiscount.toFixed(2)
  391. },
  392. getOrderDetailByOrderId(id){
  393. this.$api.getOrderDetailByOrderId({
  394. id:id
  395. }).then(res=>{
  396. this.order= res.data.data
  397. this.calculatePrice()
  398. })
  399. },
  400. payItem(num){
  401. console.log('this.userInfo.balance',this.userInfo.balance*1)
  402. console.log('this.price',this.allPrice*1)
  403. if (this.userInfo.balance*1 < this.allPrice*1 && num == 1){
  404. return
  405. }
  406. this.curServiceTab = num
  407. },
  408. closePayPopup(){
  409. this.$refs.popup.close()
  410. },
  411. }
  412. }
  413. </script>
  414. <style>
  415. @import '/common/css/common.css';
  416. @import './index.rpx.scss';</style>