confirm.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <template>
  2. <view class="box">
  3. <view class="topBox" :style="{background:'#'+themeColor}"></view>
  4. <view class="yuanhu" :style="{background:'#'+themeColor}"></view>
  5. <view class="goodsBox">
  6. <view class="goodsBoxLeft">
  7. <image :src="goodsInfo.ImgList[0].url" mode="" v-if="goodsInfo.ImgList.length>0" class="hotGoodsLineImg"></image>
  8. <image src="../../static/timg/noimg.png" v-else class="hotGoodsLineImg" ></image>
  9. </view>
  10. <view class="goodsBoxRgiht">
  11. <view class="goodsName">{{goodsInfo.name}}</view>
  12. <view class="goodsBottom">
  13. <view class="goodsPrice"> <span class="goodsPrice1">¥</span> {{goodsInfo.salePrice?goodsInfo.salePrice:goodsInfo.scribingPrice}}
  14. <span v-if="goodsInfo.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'">万</span>
  15. </view>
  16. <view class="numJsbox">
  17. <view class="numJj" @click="calculation(1)">-</view>
  18. <view class="goodsnum">
  19. <input type="number" value="" v-model="goodsnum" class="goodsnumInput"/>
  20. </view>
  21. <view class="numJj" @click="calculation(2)">+</view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="cont">
  27. <view class="contKk">
  28. <view class="contLine">
  29. <view class="contlineLeft">服务门店</view>
  30. <view class="contlineRight">{{shopName}}</view>
  31. </view>
  32. <view class="contLine">
  33. <view class="contlineLeft">车牌号</view>
  34. <view class="contlineRight" @click="goCarlist">
  35. <span>{{carInfo.plateNumber}}</span>
  36. <image src="../../static/timg/icon_arrow_right.png" mode="" class="contlineRightJt"></image>
  37. </view>
  38. </view>
  39. <view class="contLine">
  40. <view class="contlineLeft">车型</view>
  41. <view class="contlineRight carModelRight" @click="goCarlist">
  42. <span class="carModel">{{carInfo.carModel?carInfo.carModel:'选择车辆'}}</span>
  43. <image src="../../static/timg/icon_arrow_right.png" mode="" class="contlineRightJt"></image>
  44. </view>
  45. </view>
  46. <view class="contLine">
  47. <view class="contlineLeft">联系人</view>
  48. <view class="contlineRight">
  49. <input type="text" v-model="customerName" placeholder="请输入联系人姓名" class="contlineRightInput">
  50. </view>
  51. </view>
  52. <view class="contLine " style="border-bottom: none;">
  53. <view class="contlineLeft">手机号</view>
  54. <view class="contlineRight">
  55. <input type="text" v-model="mobilePhone" placeholder="请输入联系人手机号" class="contlineRightInput">
  56. </view>
  57. </view>
  58. </view>
  59. <view class="contKk" style="margin-top:20rpx;">
  60. <view class="contLine " style="border-bottom: none;">
  61. <view class="contlineLeft">订单备注</view>
  62. <view class="contlineRight">
  63. <input type="text" v-model="comment" placeholder="请输入" class="contlineRightInput2">
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view style="height:120rpx"></view>
  69. <view class="bottomBox" >
  70. <view class="bottomLeft">
  71. <view class="bottomLeftLine">合计 <span>¥</span> <span class="bottomPrice">{{totalMoney}}</span> </view>
  72. <view class="bottomLeftLine2">总优惠:¥{{yhMoney}}</view>
  73. </view>
  74. <view class="bottomBtn" :style="{background:'#'+themeColor}" @click="submit">提交订单</view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. export default {
  80. components: {
  81. },
  82. data() {
  83. return {
  84. userInfo:'',
  85. goodsnum:1,
  86. id:'',
  87. info:'',
  88. carInfo:'',
  89. shopID:'',
  90. shopName:'',
  91. goodsInfo:'',
  92. totalMoney:'',
  93. yhMoney:0,
  94. customerName:'',
  95. mobilePhone:'',
  96. comment:'',
  97. mydata:'',
  98. orderData:'',
  99. shareId:'',
  100. themeColor:'',
  101. }
  102. },
  103. onLoad(opt) {
  104. this.shopID=opt.shopID;
  105. this.shopName=opt.shopName;
  106. this.goodsnum=opt.itemQty;
  107. if(opt.shareId){
  108. this.shareId=opt.shareId
  109. }
  110. //console.log(this.carInfo)
  111. this.themeColor = uni.getStorageSync("themeColor");
  112. this.userInfo = uni.getStorageSync("userInfo");
  113. this.goodsInfo=uni.getStorageSync("goodsDetail");
  114. this.jsMoney()
  115. //this.openGoodsDetailById()
  116. /* var a=[
  117. {name:1},{name:2}
  118. ]
  119. var b=a.map(i=>i.name);
  120. console.log(b) */
  121. this.$http('openreservation/getInfo', {
  122. lat: '',
  123. lng:'',
  124. }, 'GET').then(res => {
  125. this.mydata = res.data
  126. this.mobilePhone=this.mydata.customerInfo.mobilePhone
  127. })
  128. },
  129. onShow() {
  130. this.carInfo=this.$store.state.carInfo;
  131. },
  132. methods: {
  133. submit(){
  134. if(!this.carInfo){
  135. uni.showToast({
  136. title: '请选择车辆',
  137. icon: 'none',
  138. duration: 3000
  139. });
  140. return false;
  141. }
  142. if(!this.carInfo.plateNumber){
  143. uni.showToast({
  144. title: '请选择车辆',
  145. icon: 'none',
  146. duration: 3000
  147. });
  148. return false;
  149. }
  150. var jsonArray = [];
  151. var obj={
  152. itemId:this.goodsInfo.id,
  153. itemName:this.goodsInfo.name,
  154. itemQty:this.goodsnum,
  155. salePrice:this.goodsInfo.salePrice,
  156. totalPrice:this.totalMoney
  157. }
  158. jsonArray.push(obj)
  159. //"bizType:1商品2项目3套餐
  160. var params={
  161. sheetType:this.goodsInfo.bizType,
  162. sheetContent:this.goodsInfo.name,
  163. customerName:this.customerName,
  164. mobilePhone:this.mobilePhone,
  165. plateNumber:this.carInfo.plateNumber,
  166. carModel:this.carInfo.carModel,
  167. totalMoney:this.totalMoney,
  168. shopId:this.shopID,
  169. comment:this.comment,
  170. sheetDetail:JSON.stringify(jsonArray),
  171. shareId:this.shareId
  172. }
  173. uni.showLoading({
  174. title: '加载中'
  175. })
  176. this.$http('openMallOrder/submitOrder', params,'POST').then(res => {
  177. uni.hideLoading();
  178. if(res.code==0){
  179. this.orderData=res.data
  180. this.unifiedPay(res.data)
  181. }else{
  182. uni.showToast({
  183. title: res.msg,
  184. icon: 'none',
  185. duration: 3000
  186. });
  187. }
  188. })
  189. },
  190. unifiedPay(res){
  191. this.$http('openMallOrder/unifiedPay', {
  192. sheetId:res.id
  193. },'POST').then(res => {
  194. if(res.code==0){
  195. this.requestPayment(res.data)
  196. }else{
  197. uni.showToast({
  198. title: res.msg,
  199. icon: 'none',
  200. duration: 3000
  201. });
  202. }
  203. })
  204. },
  205. requestPayment(res){
  206. var payInfo=res;
  207. //console.log(payInfo)
  208. //console.log(String(Date.now()))
  209. var that=this;
  210. uni.requestPayment({
  211. provider: 'wxpay',
  212. //timeStamp: String(Date.now()),
  213. timeStamp: payInfo.timeStamp,
  214. nonceStr: payInfo.nonceStr,
  215. package:payInfo.package,
  216. signType: payInfo.signType,
  217. paySign: payInfo.paySign,
  218. appid:payInfo.appId,
  219. /* provider: 'wxpay',
  220. orderInfo:{
  221. "appid":payInfo.appid, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  222. "noncestr": payInfo.nonceStr, // 随机字符串
  223. "package": "Sign=WXPay", // 固定值
  224. "partnerid":payInfo.mchId, // 微信支付商户号
  225. "prepayid": payInfo.prepayId, // 统一下单订单号
  226. "timeStamp": String(Date.now()), // 时间戳(单位:秒)
  227. "sign": payInfo.sign // 签名,这里用的 MD5/RSA 签名
  228. }, */
  229. success: function (res) {
  230. console.log('success:' + JSON.stringify(res));
  231. uni.showToast({
  232. title: '支付成功',
  233. icon:'none',
  234. duration: 2000
  235. });
  236. if((that.orderData.sheetType==1)||(that.orderData.sheetType==2)||(that.orderData.sheetType==3)){
  237. uni.redirectTo({
  238. url: "../user/myOrder/mallOrderDetail?id=" + that.orderData.id +"&SheetType=" + that.orderData.sheetType
  239. })
  240. }
  241. },
  242. fail: function (err) {
  243. console.log(err)
  244. uni.showToast({
  245. title: '支付失败',
  246. icon:'none',
  247. duration: 2000
  248. });
  249. console.log(that.orderData)
  250. if(that.orderData.sheetType==1||that.orderData.sheetType==2||that.orderData.sheetType==3){
  251. console.log("商城订单s")
  252. uni.redirectTo({
  253. url: "../user/myOrder/mallOrderDetail?id=" + that.orderData.id +"&SheetType=" + that.orderData.sheetType
  254. })
  255. }
  256. }
  257. });
  258. },
  259. openGoodsDetailById(){
  260. this.$http('openMall/openGoodsDetailById', {
  261. id:this.id
  262. },'GET').then(res => {
  263. this.info=res.data
  264. })
  265. },
  266. goINdex(){
  267. uni.switchTab({
  268. url:'../index/index'
  269. })
  270. },
  271. goCarlist(){
  272. uni.navigateTo({
  273. url:'../user/addCar/cailist'
  274. })
  275. },
  276. calculation(type){
  277. if(type==1){
  278. if(this.goodsnum>1){
  279. this.goodsnum--
  280. this.jsMoney()
  281. }
  282. }else{
  283. if(this.goodsInfo.oneQty>this.goodsnum){
  284. this.goodsnum++
  285. this.jsMoney()
  286. }
  287. }
  288. },
  289. jsMoney(){
  290. if(this.goodsInfo.salePrice){
  291. if(this.goodsInfo.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'){
  292. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum*10000;
  293. }else{
  294. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum
  295. }
  296. if(this.goodsInfo.scribingPrice){
  297. var wyh=this.goodsInfo.scribingPrice*this.goodsnum;
  298. this.yhMoney=wyh-this.totalMoney;
  299. console.log(this.yhMoney)
  300. this.yhMoney=this.yhMoney.toFixed(2)
  301. }else{
  302. this.yhMoney=0
  303. }
  304. this.totalMoney=this.totalMoney.toFixed(2)
  305. }else{
  306. this.totalMoney=this.goodsInfo.scribingPrice*this.goodsnum
  307. this.totalMoney=this.totalMoney.toFixed(2)
  308. this.yhMoney=0
  309. }
  310. }
  311. }
  312. }
  313. </script>
  314. <style scoped lang="less">
  315. .bottomBox{
  316. width: 750rpx;
  317. height: 120rpx;
  318. background: #FFFFFF;
  319. box-shadow: 0px -2px 10rpx 0px rgba(153,153,153,0.2000);
  320. display: flex;
  321. justify-content: space-between;
  322. position: fixed;
  323. left: 0;
  324. bottom: 0;
  325. }
  326. .bottomLeft{
  327. padding-top: 23rpx;
  328. padding-left: 30rpx;
  329. }
  330. .bottomLeftLine{
  331. color: #666666;
  332. font-size: 24rpx;
  333. }
  334. .bottomLeftLine span{
  335. color: #FF0000;
  336. }
  337. .bottomPrice{
  338. font-size: 32rpx;
  339. font-weight: 500;
  340. }
  341. .bottomLeftLine2{
  342. color: #999999;
  343. line-height: 33rpx;
  344. font-size: 24rpx;
  345. }
  346. .bottomBtn{
  347. width: 204rpx;
  348. height: 74rpx;
  349. background: #D53533;
  350. border-radius: 37rpx;
  351. text-align: center;
  352. line-height: 74rpx;
  353. color: #FFFFFF;
  354. font-size: 30rpx;
  355. margin-top: 23rpx;
  356. margin-right: 30rpx;
  357. }
  358. .cont{
  359. padding: 20rpx 24rpx;
  360. }
  361. .contKk{
  362. background: #FFFFFF;border-radius: 10rpx;
  363. padding: 0 20rpx;
  364. }
  365. .contLine{
  366. display: flex;
  367. justify-content: space-between;
  368. font-size: 28rpx;
  369. padding: 30rpx 0;
  370. border-bottom: 1px solid #EEEEEE;
  371. }
  372. .contlineLeft{
  373. color: #666666;
  374. line-height: 40rpx;
  375. }
  376. .carModel{
  377. width: 400rpx;
  378. display: inline-block;
  379. white-space: nowrap;
  380. overflow: hidden;
  381. text-overflow: ellipsis;
  382. }
  383. .carModelRight{
  384. display: flex;justify-content: space-between;
  385. }
  386. .contlineRight{
  387. color: #333333;
  388. line-height: 40rpx;
  389. white-space: nowrap;
  390. overflow: hidden;
  391. text-overflow: ellipsis;
  392. width: 450rpx;
  393. text-align: right;
  394. }
  395. .contlineRightInput{
  396. color: #333333;
  397. }
  398. .contlineRightJt{
  399. width: 12rpx;
  400. height: 20rpx;
  401. margin-left: 20rpx;
  402. margin-top: 10rpx;
  403. }
  404. .box{
  405. background: #F4F5F7;
  406. min-height: 100vh;
  407. }
  408. .topBox{
  409. height: 140rpx;
  410. background: #FF0000;
  411. width: 750rpx;
  412. }
  413. .yuanhu{
  414. width: 750rpx;
  415. height: 30rpx;
  416. background: #FF0000;
  417. border-radius: 0 0 100% 100%;
  418. }
  419. .goodsBox{
  420. width: 662rpx;
  421. height: 194rpx;
  422. background: #FFFFFF;
  423. border-radius: 16rpx;
  424. margin-left: 24rpx;
  425. margin-top: -100rpx;
  426. padding: 20rpx;
  427. display: flex;
  428. }
  429. .goodsBoxLeft{
  430. width: 208rpx;
  431. height: 194rpx;
  432. border-radius: 16rpx;
  433. border: 1px solid #EEEEEE;
  434. }
  435. .hotGoodsLineImg{
  436. width: 208rpx;
  437. height: 194rpx;
  438. }
  439. .goodsnum{
  440. width: 88rpx;
  441. height: 44rpx;
  442. background: #F4F5F7;
  443. line-height: 44rpx;
  444. text-align: center;
  445. font-weight: 500;
  446. color: #333333;
  447. font-size: 24rpx;
  448. margin: 0 4rpx;
  449. }
  450. .goodsnumInput{
  451. width: 88rpx;
  452. height: 44rpx;
  453. background: #F4F5F7;
  454. line-height: 44rpx;
  455. text-align: center;
  456. font-weight: 500;
  457. color: #333333;
  458. font-size: 24rpx;
  459. }
  460. .numJsbox{
  461. display: flex;
  462. }
  463. .numJj{
  464. width: 44rpx;
  465. height: 44rpx;
  466. background: #F4F5F7;
  467. border-radius: 0px 6rpx 6rpx 0px;
  468. text-align: center;
  469. line-height: 44rpx;
  470. font-size: 32rpx;
  471. color: #999999;
  472. }
  473. .goodsnum{
  474. width: 88rpx;
  475. height: 44rpx;
  476. background: #F4F5F7;
  477. line-height: 44rpx;
  478. text-align: center;
  479. font-weight: 500;
  480. color: #333333;
  481. font-size: 24rpx;
  482. margin: 0 4rpx;
  483. }
  484. .goodsBottom{
  485. display: flex;
  486. justify-content: space-between;
  487. padding-top: 60rpx;
  488. }
  489. .goodsPrice{
  490. color: #333333;
  491. font-size: 32rpx;
  492. font-weight: 500;
  493. }
  494. .goodsPrice1{
  495. color: #333333;
  496. font-size: 22rpx;
  497. }
  498. .goodsName{
  499. font-weight: 400;
  500. color: #333333;
  501. line-height: 40rpx;
  502. font-size: 28rpx;
  503. height: 80rpx;
  504. text-overflow: -o-ellipsis-lastline;
  505. overflow: hidden;
  506. text-overflow: ellipsis;
  507. display: -webkit-box;
  508. -webkit-line-clamp: 2;
  509. line-clamp: 2;
  510. -webkit-box-orient: vertical;
  511. width: 420rpx;
  512. }
  513. .goodsBoxRgiht{
  514. padding-left: 24rpx;
  515. }
  516. </style>