confirm.vue 13 KB

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