confirm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  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. }
  286. }
  287. });
  288. },
  289. openGoodsDetailById(){
  290. this.$http('openMall/openGoodsDetailById', {
  291. id:this.id
  292. },'GET').then(res => {
  293. this.info=res.data
  294. })
  295. },
  296. goINdex(){
  297. uni.switchTab({
  298. url:'../index/index'
  299. })
  300. },
  301. goCarlist(){
  302. uni.navigateTo({
  303. url:'../user/addCar/cailist'
  304. })
  305. },
  306. inputChange(){
  307. //console.log(this.goodsnum)
  308. if(this.goodsInfo.oneQty){
  309. if(this.goodsInfo.oneQty>this.goodsnum||this.goodsInfo.oneQty==this.goodsnum){
  310. this.jsMoney()
  311. }else{
  312. uni.showToast({
  313. title: '超过限购次数',
  314. icon:'none',
  315. duration: 2000
  316. });
  317. this.goodsnum=this.goodsInfo.oneQty
  318. this.jsMoney()
  319. }
  320. }else{
  321. this.jsMoney()
  322. }
  323. },
  324. calculation(type){
  325. console.log(type)
  326. console.log(this.goodsnum)
  327. if(type==1){
  328. if(this.goodsnum>1){
  329. this.goodsnum--
  330. this.jsMoney()
  331. }
  332. }else{
  333. if(this.goodsInfo.oneQty){
  334. if(this.goodsInfo.oneQty>this.goodsnum){
  335. this.goodsnum++
  336. this.jsMoney()
  337. }
  338. }else{
  339. this.goodsnum++
  340. this.jsMoney()
  341. }
  342. }
  343. },
  344. jsMoney(){
  345. if(this.goodsInfo.salePrice){
  346. if(this.goodsInfo.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'){
  347. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum*10000;
  348. }else{
  349. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum
  350. }
  351. if(this.goodsInfo.scribingPrice){
  352. var wyh=this.goodsInfo.scribingPrice*this.goodsnum;
  353. this.yhMoney=wyh-this.totalMoney;
  354. console.log(this.yhMoney)
  355. this.yhMoney=this.yhMoney.toFixed(2)
  356. }else{
  357. this.yhMoney=0
  358. }
  359. this.totalMoney=this.totalMoney.toFixed(2)
  360. }else{
  361. this.totalMoney=this.goodsInfo.scribingPrice*this.goodsnum
  362. this.totalMoney=this.totalMoney.toFixed(2)
  363. this.yhMoney=0
  364. }
  365. }
  366. }
  367. }
  368. </script>
  369. <style scoped lang="less">
  370. .bottomBox{
  371. width: 750rpx;
  372. height: 120rpx;
  373. background: #FFFFFF;
  374. box-shadow: 0px -2px 10rpx 0px rgba(153,153,153,0.2000);
  375. display: flex;
  376. justify-content: space-between;
  377. position: fixed;
  378. left: 0;
  379. bottom: 0;
  380. }
  381. .bottomLeft{
  382. padding-top: 23rpx;
  383. padding-left: 30rpx;
  384. }
  385. .bottomLeftLine{
  386. color: #666666;
  387. font-size: 24rpx;
  388. }
  389. .bottomLeftLine span{
  390. color: #EC0F0A;
  391. }
  392. .bottomPrice{
  393. font-size: 32rpx;
  394. font-weight: 500;
  395. }
  396. .bottomLeftLine2{
  397. color: #999999;
  398. line-height: 33rpx;
  399. font-size: 24rpx;
  400. }
  401. .bottomBtn{
  402. width: 204rpx;
  403. height: 74rpx;
  404. background: #EC0F0A;
  405. border-radius: 37rpx;
  406. text-align: center;
  407. line-height: 74rpx;
  408. color: #FFFFFF;
  409. font-size: 30rpx;
  410. margin-top: 23rpx;
  411. margin-right: 30rpx;
  412. }
  413. .cont{
  414. padding: 20rpx 24rpx;
  415. }
  416. .contKk{
  417. background: #FFFFFF;border-radius: 10rpx;
  418. padding: 0 20rpx;
  419. }
  420. .contLine{
  421. display: flex;
  422. justify-content: space-between;
  423. font-size: 28rpx;
  424. padding: 30rpx 0;
  425. border-bottom: 1px solid #EEEEEE;
  426. }
  427. .contLine2{
  428. font-size: 28rpx;
  429. padding: 30rpx 0;
  430. }
  431. .contlineLeft{
  432. color: #666666;
  433. line-height: 40rpx;
  434. }
  435. .carModel{
  436. width: 400rpx;
  437. display: inline-block;
  438. white-space: nowrap;
  439. overflow: hidden;
  440. text-overflow: ellipsis;
  441. }
  442. .carModelRight{
  443. display: flex;justify-content: space-between;
  444. }
  445. .contlineRight{
  446. color: #333333;
  447. line-height: 40rpx;
  448. white-space: nowrap;
  449. overflow: hidden;
  450. text-overflow: ellipsis;
  451. width: 500rpx;
  452. text-align: right;
  453. }
  454. .contlineRight2{
  455. color: #333333;
  456. line-height: 40rpx;
  457. width: 550rpx;
  458. text-align: right;
  459. }
  460. .contlineRightInput{
  461. color: #333333;
  462. }
  463. .contlineRightJt{
  464. width: 12rpx;
  465. height: 20rpx;
  466. margin-left: 20rpx;
  467. margin-top: 10rpx;
  468. }
  469. .box{
  470. background: #F4F5F7;
  471. min-height: 100vh;
  472. }
  473. .topBox{
  474. height: 140rpx;
  475. background: #EC0F0A;
  476. width: 750rpx;
  477. }
  478. .yuanhu{
  479. width: 750rpx;
  480. height: 30rpx;
  481. background: #EC0F0A;
  482. border-radius: 0 0 100% 100%;
  483. }
  484. .goodsBox{
  485. width: 662rpx;
  486. height: 194rpx;
  487. background: #FFFFFF;
  488. border-radius: 16rpx;
  489. margin-left: 24rpx;
  490. margin-top: -100rpx;
  491. padding: 20rpx;
  492. display: flex;
  493. }
  494. .goodsBoxLeft{
  495. width: 208rpx;
  496. height: 194rpx;
  497. border-radius: 16rpx;
  498. border: 1px solid #EEEEEE;
  499. }
  500. .hotGoodsLineImg{
  501. width: 208rpx;
  502. height: 194rpx;
  503. }
  504. .goodsnum{
  505. width: 88rpx;
  506. height: 44rpx;
  507. background: #F4F5F7;
  508. line-height: 44rpx;
  509. text-align: center;
  510. font-weight: 500;
  511. color: #333333;
  512. font-size: 24rpx;
  513. margin: 0 4rpx;
  514. }
  515. .goodsnumInput{
  516. width: 80rpx;
  517. height: 44rpx;
  518. background: #F4F5F7;
  519. line-height: 44rpx;
  520. text-align: center;
  521. font-weight: 500;
  522. color: #333333;
  523. font-size: 24rpx;
  524. }
  525. .numJsbox{
  526. display: flex;
  527. }
  528. .numJj{
  529. width: 60rpx;
  530. height: 44rpx;
  531. background: #F4F5F7;
  532. border-radius: 0px 6rpx 6rpx 0px;
  533. text-align: center;
  534. line-height: 44rpx;
  535. font-size: 32rpx;
  536. color: #999999;
  537. }
  538. .goodsnum{
  539. width: 80rpx;
  540. height: 44rpx;
  541. background: #F4F5F7;
  542. line-height: 44rpx;
  543. text-align: center;
  544. font-weight: 500;
  545. color: #333333;
  546. font-size: 24rpx;
  547. margin: 0 4rpx;
  548. }
  549. .goodsBottom{
  550. display: flex;
  551. justify-content: space-between;
  552. padding-top: 60rpx;
  553. }
  554. .goodsPrice{
  555. color: #333333;
  556. font-size: 32rpx;
  557. font-weight: 500;
  558. }
  559. .goodsPrice1{
  560. color: #333333;
  561. font-size: 22rpx;
  562. }
  563. .goodsName{
  564. font-weight: 400;
  565. color: #333333;
  566. line-height: 40rpx;
  567. font-size: 28rpx;
  568. height: 80rpx;
  569. text-overflow: -o-ellipsis-lastline;
  570. overflow: hidden;
  571. text-overflow: ellipsis;
  572. display: -webkit-box;
  573. -webkit-line-clamp: 2;
  574. line-clamp: 2;
  575. -webkit-box-orient: vertical;
  576. width: 420rpx;
  577. }
  578. .goodsBoxRgiht{
  579. padding-left: 24rpx;
  580. }
  581. .carModelCK{
  582. font-weight: 400;
  583. font-size: 24rpx;
  584. color: #666666;
  585. width: 550rpx;
  586. white-space: nowrap;
  587. overflow: hidden;
  588. text-overflow: ellipsis;
  589. }
  590. </style>