confirm.vue 14 KB

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