confirm.vue 14 KB

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