confirm.vue 13 KB

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