getOrder.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  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 >18792703003</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. export default {
  83. components: {
  84. uniSteps
  85. },
  86. data() {
  87. return {
  88. stepIndex: 0, // 当前步奏下标
  89. serverIndex: 0, // 选择服务下标
  90. itemList: [ // 服务列表
  91. {
  92. id: 1,
  93. name: '极速快洗',
  94. price: 10
  95. },
  96. {
  97. id: 12,
  98. name: '精致洗',
  99. price: 20
  100. },
  101. {
  102. id: 13,
  103. name: '打蜡洗',
  104. price: 30
  105. }
  106. ],
  107. isRead: '', // 是否同意协议
  108. couponList: [
  109. {
  110. id: 23432445,
  111. name: "满100减50",
  112. price: 100,
  113. yxTime: "2020-05-16",
  114. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  115. checked: false
  116. },
  117. {
  118. id: 3544355,
  119. name: "满100减50",
  120. price: 100,
  121. yxTime: "2020-05-16",
  122. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  123. checked: false
  124. },
  125. {
  126. id: 234234234,
  127. name: "满100减50",
  128. price: 100,
  129. yxTime: "2020-05-16",
  130. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  131. checked: false
  132. },
  133. {
  134. id: 66264646,
  135. name: "满100减50",
  136. price: 100,
  137. yxTime: "2020-05-16",
  138. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  139. checked: false
  140. },
  141. {
  142. id: 9794694698,
  143. name: "满100减50",
  144. price: 100,
  145. yxTime: "2020-05-16",
  146. remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
  147. checked: false
  148. }
  149. ], // 用户可用优惠券
  150. checkedCoupon: null, // 用户当前所选优惠券
  151. amount: 0, // 所选服务项目总金额
  152. couponAmount: 0, // 优惠券优惠金额
  153. finalAmount: 0, // 用户最终所需支付金额
  154. }
  155. },
  156. onLoad(option) {
  157. uni.removeStorageSync('stepIndex')
  158. // 注册全局监听事件
  159. uni.$once('read', this.read)
  160. },
  161. onUnload() {
  162. uni.removeStorageSync('stepIndex')
  163. },
  164. onShow() {
  165. const index = uni.getStorageSync('stepIndex')
  166. this.stepIndex = index ? index : 0
  167. console.log(this.stepIndex)
  168. },
  169. methods: {
  170. // 获取服务列表
  171. getServerList () {
  172. },
  173. // 选择服务项目
  174. chooseItem(index) {
  175. this.serverIndex = index
  176. this.amount = this.itemList[index].price
  177. this.getFinalAmount()
  178. },
  179. // 下一步
  180. nextStep() {
  181. this.stepIndex = this.stepIndex===0 ? 1 : 2
  182. uni.setStorageSync('stepIndex', this.stepIndex)
  183. },
  184. // 已阅读
  185. read (e) {
  186. this.isRead = e.msg
  187. },
  188. // 获取用户可用优惠券
  189. getCouponList () {
  190. },
  191. // 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
  192. formatCouponData (){
  193. let arr = []
  194. let _this = this
  195. this.couponList.map(item => {
  196. let data = {}
  197. data.id = item.couponReceivesId
  198. if (item.couponType == 'DISCOUNT') {
  199. console.log(_this.amount, '_this.amount')
  200. data.subAmount = Number((_this.amount * (1 - item.subAmount)).toFixed(2))
  201. } else {
  202. data.subAmount = item.couponType == 'FULLSUB' ? item.subAmount : item.price
  203. }
  204. arr.push(data)
  205. })
  206. console.log(arr, 'arr')
  207. // 比较数据中优惠金额最大的值 并返回该对象
  208. let obj = arr.reduce((p, v) => p.subAmount < v.subAmount ? v : p)
  209. console.log(obj)
  210. let p = this.couponList.find(item => item.couponReceivesId == obj.id)
  211. // 订单金额为0时,默认不使用优惠卷
  212. if (this.amount != 0){
  213. this.checkedCoupon = p
  214. this.couponAmount = obj.subAmount > this.amount ? this.amount : obj.subAmount
  215. } else {
  216. this.checkedCoupon = null
  217. this.couponAmount = 0
  218. }
  219. // 计算合计
  220. this.getFinalAmount()
  221. },
  222. // 计算合计
  223. getFinalAmount () {
  224. let ret = this.amount - this.couponAmount
  225. this.finalAmount = ret.toFixed(2)
  226. },
  227. // 选择优惠券
  228. intoChooseCoupon () {
  229. uni.navigateTo({
  230. url: `/pages/coupon/chooseCoupon/chooseCoupon?list=${encodeURIComponent(JSON.stringify(this.couponList))}`
  231. })
  232. },
  233. // 打开服务协议
  234. intoAgreement () {
  235. uni.navigateTo({
  236. url: '/pages/agreement/agreement'
  237. })
  238. },
  239. // 去付款
  240. toPay (){
  241. // 付款成功后开始洗车
  242. uni.redirectTo({
  243. url:"/pages/work/index/index"
  244. })
  245. }
  246. }
  247. }
  248. </script>
  249. <style lang="scss">
  250. page{
  251. height: 100%;
  252. }
  253. .order-content{
  254. width: 100%;
  255. height: 100%;
  256. display: flex;
  257. flex-direction: column;
  258. .step{
  259. padding: 40rpx 0;
  260. }
  261. .step-content{
  262. flex: 1;
  263. width: 100%;
  264. display: flex;
  265. flex-direction: column;
  266. .step-item{
  267. width: 100%;
  268. display: flex;
  269. flex-direction: column;
  270. align-items: center;
  271. flex: 1;
  272. }
  273. .step-one{
  274. text{
  275. color: #999;
  276. margin: 40rpx 0;
  277. }
  278. }
  279. .step-two{
  280. background-color: #F8F8F8;
  281. .item{
  282. background-color: #fff;
  283. width: 80%;
  284. height: 40%;
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. margin-top: 20rpx;
  289. padding-top: 20rpx;
  290. image{
  291. width: 80%;
  292. flex: 1;
  293. }
  294. }
  295. .top{
  296. text{
  297. color: #df928e;
  298. font-size: 24rpx;
  299. margin-bottom: 20rpx;
  300. }
  301. .care{
  302. padding: 10rpx 20rpx;
  303. background-color: #ff805b;
  304. border-radius: 30rpx;
  305. color: #fff;
  306. font-size: 24rpx;
  307. margin-bottom: 10rpx;
  308. }
  309. }
  310. .bottom{
  311. text{
  312. font-size: 24rpx;
  313. color: #333;
  314. }
  315. }
  316. }
  317. .step-three{
  318. .choose{
  319. width: 100%;
  320. height: auto;
  321. padding-bottom: 60rpx;
  322. display: flex;
  323. flex-direction: column;
  324. align-items: center;
  325. border-bottom: 1px solid #eee;
  326. .title{
  327. color: #666;
  328. }
  329. .list{
  330. width: 100%;
  331. display: flex;
  332. justify-content: space-around;
  333. padding: 0 20rpx;
  334. .item{
  335. width: 30%;
  336. height: 140rpx;
  337. display: flex;
  338. flex-direction: column;
  339. align-items: center;
  340. justify-content: center;
  341. border: 1px solid #eee;
  342. border-radius: 15rpx;
  343. margin-top: 30rpx;
  344. color: #999;
  345. .price{
  346. font-size: 34rpx;
  347. margin-top: 10rpx;
  348. }
  349. }
  350. .avtive{
  351. color: #333;
  352. border-color: rgb(255,0,0);
  353. .price{
  354. color: rgb(255,0,0);
  355. }
  356. }
  357. }
  358. }
  359. .choose-content{
  360. flex: 1;
  361. width: 100%;
  362. .choose-item{
  363. width: 100%;
  364. .item{
  365. padding: 0 30rpx;
  366. }
  367. }
  368. .item{
  369. width: 100%;
  370. height: 100rpx;
  371. display: flex;
  372. align-items: center;
  373. justify-content: space-between;
  374. border-bottom: 1px solid #eee;
  375. .coopon{
  376. color: rgb(255,0,0);
  377. }
  378. }
  379. .phone{
  380. border-bottom: none;
  381. }
  382. .read{
  383. width: 100%;
  384. border-top: 1px solid #eee;
  385. padding-top: 40rpx;
  386. display: flex;
  387. justify-content: center;
  388. text{
  389. color: #999;
  390. }
  391. text:last-child{
  392. color: #ff9ba5;
  393. }
  394. }
  395. }
  396. }
  397. .step-footer{
  398. width: 100%;
  399. background-color: #fff;
  400. .next-button{
  401. margin: 0;
  402. border-radius: 0;
  403. padding: 10rpx 0;
  404. }
  405. .pay{
  406. width: 100%;
  407. height: 100%;
  408. padding: 10rpx;
  409. border-top: 1px solid #eee;
  410. display: flex;
  411. align-items: center;
  412. justify-content: flex-end;
  413. .amount{
  414. color: rgb(255,0,0);
  415. font-size: 36rpx;
  416. margin-right: 40rpx;
  417. }
  418. button{
  419. width: 200rpx;
  420. }
  421. }
  422. }
  423. }
  424. }
  425. </style>