getOrder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="order-content">
  3. <view class="step">
  4. <uni-steps :options="[{title: '停车'}, {title: '检查'}, {title: '下单'}]" :active="stepIndex" active-color="rgb(255,0,0)"></uni-steps>
  5. </view>
  6. <view class="step-content">
  7. <!-- 停车 -->
  8. <view v-if="stepIndex===0" class="step-item step-one">
  9. <text>请确认车辆是否停到指定位置</text>
  10. <image src="/static/img/step-one.png" mode="aspectFit"></image>
  11. </view>
  12. <!-- 检查 -->
  13. <view v-if="stepIndex===1" class="step-item step-two">
  14. <view class="item top">
  15. <text>-请完成以下操作-</text>
  16. <image src="/static/img/cztis.png" mode="aspectFit"></image>
  17. <view class="care">
  18. 注意:洗车过程中禁止移动车辆和上下车
  19. </view>
  20. </view>
  21. <view class="item bottom">
  22. <text>超高加装件不能清洗</text>
  23. <image src="/static/img/zyts.png" mode="aspectFit"></image>
  24. </view>
  25. </view>
  26. <!-- 下单 -->
  27. <view v-if="stepIndex===2" class="step-item step-three">
  28. <view class="choose">
  29. <view class="title">
  30. 请选择服务模式
  31. </view>
  32. <view class="list">
  33. <view :class="['item', serverIndex==index ?'avtive':'']" @click="chooseItem(index)" v-for="(item,index) in itemList" :key="index">
  34. <text>{{item.name}}</text>
  35. <text class="price">¥{{item.price}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="choose-content">
  40. <view class="choose-item">
  41. <view class="item" @click="intoChooseCoupon">
  42. <text>优惠卷</text>
  43. <view class="right">
  44. <u-icon name="gift" color="rgb(255,0,0)" size="32"></u-icon>
  45. <text class="coopon">9.8元洗车券(¥-9.8)</text>
  46. <u-icon name="arrow-right" color="rgb(255,0,0)" size="32"></u-icon>
  47. </view>
  48. </view>
  49. <view class="item phone">
  50. <text>手机号码</text>
  51. <view class="right">
  52. <text >{{userPhone}}</text>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="read">
  57. <u-radio-group v-model="isRead">
  58. <u-radio shape="square" :disabled="isRead!='read'" name="read" active-color="red" icon-size="28" label-size="28">
  59. 点击阅读并同意
  60. <text>无人洗车</text>
  61. <text @click="intoAgreement">《注意事项及服务协议》</text>
  62. </u-radio>
  63. </u-radio-group>
  64. </view>
  65. </view>
  66. </view>
  67. <view class="step-footer">
  68. <button class="next-button" @click="nextStep" v-if="stepIndex!=2" type="warn">下一步</button>
  69. <view v-else class="pay">
  70. <text>合计:</text>
  71. <text class="amount">¥{{finalAmount}}</text>
  72. <view class="">
  73. <button @click="toPay" type="warn">去付款</button>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import uniSteps from '@/components/uni-steps/uni-steps.vue'
  82. import {getUserInfo} from '@/api/login.js'
  83. export default {
  84. components: {
  85. uniSteps
  86. },
  87. data() {
  88. return {
  89. userPhone: '',
  90. stepIndex: 0, // 当前步奏下标
  91. serverIndex: 0, // 选择服务下标
  92. itemList: [ // 服务列表
  93. {
  94. id: 1,
  95. name: '极速快洗',
  96. price: 10
  97. },
  98. {
  99. id: 12,
  100. name: '精致洗',
  101. price: 20
  102. },
  103. {
  104. id: 13,
  105. name: '打蜡洗',
  106. price: 30
  107. }
  108. ],
  109. isRead: '', // 是否同意协议
  110. couponList: [
  111. {
  112. id: 23432445,
  113. name: "满100减50",
  114. price: 100,
  115. yxTime: "2020-05-16",
  116. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  117. checked: false
  118. },
  119. {
  120. id: 3544355,
  121. name: "满100减50",
  122. price: 100,
  123. yxTime: "2020-05-16",
  124. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  125. checked: false
  126. },
  127. {
  128. id: 234234234,
  129. name: "满100减50",
  130. price: 100,
  131. yxTime: "2020-05-16",
  132. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  133. checked: false
  134. },
  135. {
  136. id: 66264646,
  137. name: "满100减50",
  138. price: 100,
  139. yxTime: "2020-05-16",
  140. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  141. checked: false
  142. },
  143. {
  144. id: 9794694698,
  145. name: "满100减50",
  146. price: 100,
  147. yxTime: "2020-05-16",
  148. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  149. checked: false
  150. }
  151. ], // 用户可用优惠券
  152. checkedCoupon: null, // 用户当前所选优惠券
  153. amount: 0, // 所选服务项目总金额
  154. couponAmount: 0, // 优惠券优惠金额
  155. finalAmount: 0, // 用户最终所需支付金额
  156. }
  157. },
  158. onLoad(option) {
  159. uni.removeStorageSync('stepIndex')
  160. // 注册全局监听事件
  161. uni.$once('read', this.read)
  162. this.getUserPhone()
  163. },
  164. onUnload() {
  165. uni.removeStorageSync('stepIndex')
  166. },
  167. onShow() {
  168. const index = uni.getStorageSync('stepIndex')
  169. this.stepIndex = index ? index : 0
  170. console.log(this.stepIndex)
  171. },
  172. methods: {
  173. // 获取用户信息
  174. getUserPhone () {
  175. getUserInfo().then(res =>{
  176. console.log(res,'rrrrrrr')
  177. if(res.status == 200) {
  178. this.userPhone = res.data.mobile
  179. } else {
  180. uni.showToast({
  181. title: res.message,
  182. icon: 'none'
  183. })
  184. }
  185. })
  186. },
  187. // 获取服务列表
  188. getServerList () {
  189. },
  190. // 选择服务项目
  191. chooseItem(index) {
  192. this.serverIndex = index
  193. this.amount = this.itemList[index].price
  194. this.getFinalAmount()
  195. },
  196. // 下一步
  197. nextStep() {
  198. this.stepIndex = this.stepIndex===0 ? 1 : 2
  199. uni.setStorageSync('stepIndex', this.stepIndex)
  200. },
  201. // 已阅读
  202. read (e) {
  203. this.isRead = e.msg
  204. },
  205. // 获取用户可用优惠券
  206. getCouponList () {
  207. },
  208. // 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
  209. formatCouponData (){
  210. let arr = []
  211. let _this = this
  212. this.couponList.map(item => {
  213. let data = {}
  214. data.id = item.couponReceivesId
  215. if (item.couponType == 'DISCOUNT') {
  216. console.log(_this.amount, '_this.amount')
  217. data.subAmount = Number((_this.amount * (1 - item.subAmount)).toFixed(2))
  218. } else {
  219. data.subAmount = item.couponType == 'FULLSUB' ? item.subAmount : item.price
  220. }
  221. arr.push(data)
  222. })
  223. console.log(arr, 'arr')
  224. // 比较数据中优惠金额最大的值 并返回该对象
  225. let obj = arr.reduce((p, v) => p.subAmount < v.subAmount ? v : p)
  226. console.log(obj)
  227. let p = this.couponList.find(item => item.couponReceivesId == obj.id)
  228. // 订单金额为0时,默认不使用优惠卷
  229. if (this.amount != 0){
  230. this.checkedCoupon = p
  231. this.couponAmount = obj.subAmount > this.amount ? this.amount : obj.subAmount
  232. } else {
  233. this.checkedCoupon = null
  234. this.couponAmount = 0
  235. }
  236. // 计算合计
  237. this.getFinalAmount()
  238. },
  239. // 计算合计
  240. getFinalAmount () {
  241. let ret = this.amount - this.couponAmount
  242. this.finalAmount = ret.toFixed(2)
  243. },
  244. // 选择优惠券
  245. intoChooseCoupon () {
  246. uni.navigateTo({
  247. url: `/pages/coupon/chooseCoupon/chooseCoupon?list=${encodeURIComponent(JSON.stringify(this.couponList))}`
  248. })
  249. },
  250. // 打开服务协议
  251. intoAgreement () {
  252. uni.navigateTo({
  253. url: '/pages/agreement/agreement'
  254. })
  255. },
  256. // 去付款
  257. toPay (){
  258. // 付款成功后开始洗车
  259. uni.redirectTo({
  260. url:"/pages/work/index/index"
  261. })
  262. }
  263. }
  264. }
  265. </script>
  266. <style lang="scss">
  267. page{
  268. height: 100%;
  269. }
  270. .order-content{
  271. width: 100%;
  272. height: 100%;
  273. display: flex;
  274. flex-direction: column;
  275. .step{
  276. padding: 40rpx 0;
  277. }
  278. .step-content{
  279. flex: 1;
  280. width: 100%;
  281. display: flex;
  282. flex-direction: column;
  283. .step-item{
  284. width: 100%;
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. flex: 1;
  289. }
  290. .step-one{
  291. text{
  292. color: #999;
  293. margin: 40rpx 0;
  294. }
  295. }
  296. .step-two{
  297. background-color: #F8F8F8;
  298. .item{
  299. background-color: #fff;
  300. width: 80%;
  301. height: 40%;
  302. display: flex;
  303. flex-direction: column;
  304. align-items: center;
  305. margin-top: 20rpx;
  306. padding-top: 20rpx;
  307. image{
  308. width: 80%;
  309. flex: 1;
  310. }
  311. }
  312. .top{
  313. text{
  314. color: #df928e;
  315. font-size: 24rpx;
  316. margin-bottom: 20rpx;
  317. }
  318. .care{
  319. padding: 10rpx 20rpx;
  320. background-color: #ff805b;
  321. border-radius: 30rpx;
  322. color: #fff;
  323. font-size: 24rpx;
  324. margin-bottom: 10rpx;
  325. }
  326. }
  327. .bottom{
  328. text{
  329. font-size: 24rpx;
  330. color: #333;
  331. }
  332. }
  333. }
  334. .step-three{
  335. .choose{
  336. width: 100%;
  337. height: auto;
  338. padding-bottom: 60rpx;
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. border-bottom: 1px solid #eee;
  343. .title{
  344. color: #666;
  345. }
  346. .list{
  347. width: 100%;
  348. display: flex;
  349. justify-content: space-around;
  350. padding: 0 20rpx;
  351. .item{
  352. width: 30%;
  353. height: 140rpx;
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. justify-content: center;
  358. border: 1px solid #eee;
  359. border-radius: 15rpx;
  360. margin-top: 30rpx;
  361. color: #999;
  362. .price{
  363. font-size: 34rpx;
  364. margin-top: 10rpx;
  365. }
  366. }
  367. .avtive{
  368. color: #333;
  369. border-color: rgb(255,0,0);
  370. .price{
  371. color: rgb(255,0,0);
  372. }
  373. }
  374. }
  375. }
  376. .choose-content{
  377. flex: 1;
  378. width: 100%;
  379. .choose-item{
  380. width: 100%;
  381. .item{
  382. padding: 0 30rpx;
  383. }
  384. }
  385. .item{
  386. width: 100%;
  387. height: 100rpx;
  388. display: flex;
  389. align-items: center;
  390. justify-content: space-between;
  391. border-bottom: 1px solid #eee;
  392. .coopon{
  393. color: rgb(255,0,0);
  394. }
  395. }
  396. .phone{
  397. border-bottom: none;
  398. }
  399. .read{
  400. width: 100%;
  401. border-top: 1px solid #eee;
  402. padding-top: 40rpx;
  403. display: flex;
  404. justify-content: center;
  405. text{
  406. color: #999;
  407. }
  408. text:last-child{
  409. color: #ff9ba5;
  410. }
  411. }
  412. }
  413. }
  414. .step-footer{
  415. width: 100%;
  416. background-color: #fff;
  417. .next-button{
  418. margin: 0;
  419. border-radius: 0;
  420. padding: 10rpx 0;
  421. }
  422. .pay{
  423. width: 100%;
  424. height: 100%;
  425. padding: 10rpx;
  426. border-top: 1px solid #eee;
  427. display: flex;
  428. align-items: center;
  429. justify-content: flex-end;
  430. .amount{
  431. color: rgb(255,0,0);
  432. font-size: 36rpx;
  433. margin-right: 40rpx;
  434. }
  435. button{
  436. width: 200rpx;
  437. }
  438. }
  439. }
  440. }
  441. }
  442. </style>