confirm.vue 13 KB

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