index.vue 21 KB

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