confirm.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <view class="box">
  3. <view class="topBox" :style="{background:'#'+themeColor}"></view>
  4. <view class="yuanhu" :style="{background:'#'+themeColor}"></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" 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" :style="{background:'#'+themeColor}" @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=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){
  136. uni.showToast({
  137. title: '请选择车辆',
  138. icon: 'none',
  139. duration: 3000
  140. });
  141. return false;
  142. }
  143. if(!this.carInfo.plateNumber){
  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. setTimeout(function() {
  245. uni.redirectTo({
  246. url: "../user/myOrder/mallOrderDetail?id=" + that.orderData.id +"&SheetType=" + that.orderData.sheetType
  247. })
  248. }, 300);
  249. }
  250. },
  251. fail: function (err) {
  252. console.log(err)
  253. uni.showToast({
  254. title: '支付失败',
  255. icon:'none',
  256. duration: 2000
  257. });
  258. console.log(that.orderData)
  259. if(that.orderData.sheetType==1||that.orderData.sheetType==2||that.orderData.sheetType==3){
  260. console.log("商城订单s")
  261. uni.redirectTo({
  262. url: "../user/myOrder/mallOrderDetail?id=" + that.orderData.id +"&SheetType=" + that.orderData.sheetType
  263. })
  264. }
  265. }
  266. });
  267. },
  268. openGoodsDetailById(){
  269. this.$http('openMall/openGoodsDetailById', {
  270. id:this.id
  271. },'GET').then(res => {
  272. this.info=res.data
  273. })
  274. },
  275. goINdex(){
  276. uni.switchTab({
  277. url:'../index/index'
  278. })
  279. },
  280. goCarlist(){
  281. uni.navigateTo({
  282. url:'../user/addCar/cailist'
  283. })
  284. },
  285. calculation(type){
  286. if(type==1){
  287. if(this.goodsnum>1){
  288. this.goodsnum--
  289. this.jsMoney()
  290. }
  291. }else{
  292. if(this.goodsInfo.oneQty>this.goodsnum){
  293. this.goodsnum++
  294. this.jsMoney()
  295. }
  296. }
  297. },
  298. jsMoney(){
  299. if(this.goodsInfo.salePrice){
  300. if(this.goodsInfo.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'){
  301. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum*10000;
  302. }else{
  303. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum
  304. }
  305. if(this.goodsInfo.scribingPrice){
  306. var wyh=this.goodsInfo.scribingPrice*this.goodsnum;
  307. this.yhMoney=wyh-this.totalMoney;
  308. console.log(this.yhMoney)
  309. this.yhMoney=this.yhMoney.toFixed(2)
  310. }else{
  311. this.yhMoney=0
  312. }
  313. this.totalMoney=this.totalMoney.toFixed(2)
  314. }else{
  315. this.totalMoney=this.goodsInfo.scribingPrice*this.goodsnum
  316. this.totalMoney=this.totalMoney.toFixed(2)
  317. this.yhMoney=0
  318. }
  319. }
  320. }
  321. }
  322. </script>
  323. <style scoped lang="less">
  324. .bottomBox{
  325. width: 750rpx;
  326. height: 120rpx;
  327. background: #FFFFFF;
  328. box-shadow: 0px -2px 10rpx 0px rgba(153,153,153,0.2000);
  329. display: flex;
  330. justify-content: space-between;
  331. position: fixed;
  332. left: 0;
  333. bottom: 0;
  334. }
  335. .bottomLeft{
  336. padding-top: 23rpx;
  337. padding-left: 30rpx;
  338. }
  339. .bottomLeftLine{
  340. color: #666666;
  341. font-size: 24rpx;
  342. }
  343. .bottomLeftLine span{
  344. color: #FF0000;
  345. }
  346. .bottomPrice{
  347. font-size: 32rpx;
  348. font-weight: 500;
  349. }
  350. .bottomLeftLine2{
  351. color: #999999;
  352. line-height: 33rpx;
  353. font-size: 24rpx;
  354. }
  355. .bottomBtn{
  356. width: 204rpx;
  357. height: 74rpx;
  358. background: #D53533;
  359. border-radius: 37rpx;
  360. text-align: center;
  361. line-height: 74rpx;
  362. color: #FFFFFF;
  363. font-size: 30rpx;
  364. margin-top: 23rpx;
  365. margin-right: 30rpx;
  366. }
  367. .cont{
  368. padding: 20rpx 24rpx;
  369. }
  370. .contKk{
  371. background: #FFFFFF;border-radius: 10rpx;
  372. padding: 0 20rpx;
  373. }
  374. .contLine{
  375. display: flex;
  376. justify-content: space-between;
  377. font-size: 28rpx;
  378. padding: 30rpx 0;
  379. border-bottom: 1px solid #EEEEEE;
  380. }
  381. .contlineLeft{
  382. color: #666666;
  383. line-height: 40rpx;
  384. }
  385. .carModel{
  386. width: 400rpx;
  387. display: inline-block;
  388. white-space: nowrap;
  389. overflow: hidden;
  390. text-overflow: ellipsis;
  391. }
  392. .carModelRight{
  393. display: flex;justify-content: space-between;
  394. }
  395. .contlineRight{
  396. color: #333333;
  397. line-height: 40rpx;
  398. white-space: nowrap;
  399. overflow: hidden;
  400. text-overflow: ellipsis;
  401. width: 450rpx;
  402. text-align: right;
  403. }
  404. .contlineRightInput{
  405. color: #333333;
  406. }
  407. .contlineRightJt{
  408. width: 12rpx;
  409. height: 20rpx;
  410. margin-left: 20rpx;
  411. margin-top: 10rpx;
  412. }
  413. .box{
  414. background: #F4F5F7;
  415. min-height: 100vh;
  416. }
  417. .topBox{
  418. height: 140rpx;
  419. background: #FF0000;
  420. width: 750rpx;
  421. }
  422. .yuanhu{
  423. width: 750rpx;
  424. height: 30rpx;
  425. background: #FF0000;
  426. border-radius: 0 0 100% 100%;
  427. }
  428. .goodsBox{
  429. width: 662rpx;
  430. height: 194rpx;
  431. background: #FFFFFF;
  432. border-radius: 16rpx;
  433. margin-left: 24rpx;
  434. margin-top: -100rpx;
  435. padding: 20rpx;
  436. display: flex;
  437. }
  438. .goodsBoxLeft{
  439. width: 208rpx;
  440. height: 194rpx;
  441. border-radius: 16rpx;
  442. border: 1px solid #EEEEEE;
  443. }
  444. .hotGoodsLineImg{
  445. width: 208rpx;
  446. height: 194rpx;
  447. }
  448. .goodsnum{
  449. width: 88rpx;
  450. height: 44rpx;
  451. background: #F4F5F7;
  452. line-height: 44rpx;
  453. text-align: center;
  454. font-weight: 500;
  455. color: #333333;
  456. font-size: 24rpx;
  457. margin: 0 4rpx;
  458. }
  459. .goodsnumInput{
  460. width: 88rpx;
  461. height: 44rpx;
  462. background: #F4F5F7;
  463. line-height: 44rpx;
  464. text-align: center;
  465. font-weight: 500;
  466. color: #333333;
  467. font-size: 24rpx;
  468. }
  469. .numJsbox{
  470. display: flex;
  471. }
  472. .numJj{
  473. width: 44rpx;
  474. height: 44rpx;
  475. background: #F4F5F7;
  476. border-radius: 0px 6rpx 6rpx 0px;
  477. text-align: center;
  478. line-height: 44rpx;
  479. font-size: 32rpx;
  480. color: #999999;
  481. }
  482. .goodsnum{
  483. width: 88rpx;
  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. margin: 0 4rpx;
  492. }
  493. .goodsBottom{
  494. display: flex;
  495. justify-content: space-between;
  496. padding-top: 60rpx;
  497. }
  498. .goodsPrice{
  499. color: #333333;
  500. font-size: 32rpx;
  501. font-weight: 500;
  502. }
  503. .goodsPrice1{
  504. color: #333333;
  505. font-size: 22rpx;
  506. }
  507. .goodsName{
  508. font-weight: 400;
  509. color: #333333;
  510. line-height: 40rpx;
  511. font-size: 28rpx;
  512. height: 80rpx;
  513. text-overflow: -o-ellipsis-lastline;
  514. overflow: hidden;
  515. text-overflow: ellipsis;
  516. display: -webkit-box;
  517. -webkit-line-clamp: 2;
  518. line-clamp: 2;
  519. -webkit-box-orient: vertical;
  520. width: 420rpx;
  521. }
  522. .goodsBoxRgiht{
  523. padding-left: 24rpx;
  524. }
  525. </style>