index.vue 14 KB

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