confirm.vue 13 KB

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