confirm.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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. 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. calculation(type){
  284. if(type==1){
  285. if(this.goodsnum>1){
  286. this.goodsnum--
  287. this.jsMoney()
  288. }
  289. }else{
  290. if(this.goodsInfo.oneQty>this.goodsnum){
  291. this.goodsnum++
  292. this.jsMoney()
  293. }
  294. }
  295. },
  296. jsMoney(){
  297. if(this.goodsInfo.salePrice){
  298. if(this.goodsInfo.categoryIds=='7B97D114-C419-42B2-9C1E-0B4CA284CDA0'){
  299. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum*10000;
  300. }else{
  301. this.totalMoney=this.goodsInfo.salePrice*this.goodsnum
  302. }
  303. if(this.goodsInfo.scribingPrice){
  304. var wyh=this.goodsInfo.scribingPrice*this.goodsnum;
  305. this.yhMoney=wyh-this.totalMoney;
  306. console.log(this.yhMoney)
  307. this.yhMoney=this.yhMoney.toFixed(2)
  308. }else{
  309. this.yhMoney=0
  310. }
  311. this.totalMoney=this.totalMoney.toFixed(2)
  312. }else{
  313. this.totalMoney=this.goodsInfo.scribingPrice*this.goodsnum
  314. this.totalMoney=this.totalMoney.toFixed(2)
  315. this.yhMoney=0
  316. }
  317. }
  318. }
  319. }
  320. </script>
  321. <style scoped lang="less">
  322. .bottomBox{
  323. width: 750rpx;
  324. height: 120rpx;
  325. background: #FFFFFF;
  326. box-shadow: 0px -2px 10rpx 0px rgba(153,153,153,0.2000);
  327. display: flex;
  328. justify-content: space-between;
  329. position: fixed;
  330. left: 0;
  331. bottom: 0;
  332. }
  333. .bottomLeft{
  334. padding-top: 23rpx;
  335. padding-left: 30rpx;
  336. }
  337. .bottomLeftLine{
  338. color: #666666;
  339. font-size: 24rpx;
  340. }
  341. .bottomLeftLine span{
  342. color: #FF0000;
  343. }
  344. .bottomPrice{
  345. font-size: 32rpx;
  346. font-weight: 500;
  347. }
  348. .bottomLeftLine2{
  349. color: #999999;
  350. line-height: 33rpx;
  351. font-size: 24rpx;
  352. }
  353. .bottomBtn{
  354. width: 204rpx;
  355. height: 74rpx;
  356. background: #D53533;
  357. border-radius: 37rpx;
  358. text-align: center;
  359. line-height: 74rpx;
  360. color: #FFFFFF;
  361. font-size: 30rpx;
  362. margin-top: 23rpx;
  363. margin-right: 30rpx;
  364. }
  365. .cont{
  366. padding: 20rpx 24rpx;
  367. }
  368. .contKk{
  369. background: #FFFFFF;border-radius: 10rpx;
  370. padding: 0 20rpx;
  371. }
  372. .contLine{
  373. display: flex;
  374. justify-content: space-between;
  375. font-size: 28rpx;
  376. padding: 30rpx 0;
  377. border-bottom: 1px solid #EEEEEE;
  378. }
  379. .contlineLeft{
  380. color: #666666;
  381. line-height: 40rpx;
  382. }
  383. .carModel{
  384. width: 400rpx;
  385. display: inline-block;
  386. white-space: nowrap;
  387. overflow: hidden;
  388. text-overflow: ellipsis;
  389. }
  390. .carModelRight{
  391. display: flex;justify-content: space-between;
  392. }
  393. .contlineRight{
  394. color: #333333;
  395. line-height: 40rpx;
  396. white-space: nowrap;
  397. overflow: hidden;
  398. text-overflow: ellipsis;
  399. width: 450rpx;
  400. text-align: right;
  401. }
  402. .contlineRightInput{
  403. color: #333333;
  404. }
  405. .contlineRightJt{
  406. width: 12rpx;
  407. height: 20rpx;
  408. margin-left: 20rpx;
  409. margin-top: 10rpx;
  410. }
  411. .box{
  412. background: #F4F5F7;
  413. min-height: 100vh;
  414. }
  415. .topBox{
  416. height: 140rpx;
  417. background: #FF0000;
  418. width: 750rpx;
  419. }
  420. .yuanhu{
  421. width: 750rpx;
  422. height: 30rpx;
  423. background: #FF0000;
  424. border-radius: 0 0 100% 100%;
  425. }
  426. .goodsBox{
  427. width: 662rpx;
  428. height: 194rpx;
  429. background: #FFFFFF;
  430. border-radius: 16rpx;
  431. margin-left: 24rpx;
  432. margin-top: -100rpx;
  433. padding: 20rpx;
  434. display: flex;
  435. }
  436. .goodsBoxLeft{
  437. width: 208rpx;
  438. height: 194rpx;
  439. border-radius: 16rpx;
  440. border: 1px solid #EEEEEE;
  441. }
  442. .hotGoodsLineImg{
  443. width: 208rpx;
  444. height: 194rpx;
  445. }
  446. .goodsnum{
  447. width: 88rpx;
  448. height: 44rpx;
  449. background: #F4F5F7;
  450. line-height: 44rpx;
  451. text-align: center;
  452. font-weight: 500;
  453. color: #333333;
  454. font-size: 24rpx;
  455. margin: 0 4rpx;
  456. }
  457. .goodsnumInput{
  458. width: 88rpx;
  459. height: 44rpx;
  460. background: #F4F5F7;
  461. line-height: 44rpx;
  462. text-align: center;
  463. font-weight: 500;
  464. color: #333333;
  465. font-size: 24rpx;
  466. }
  467. .numJsbox{
  468. display: flex;
  469. }
  470. .numJj{
  471. width: 44rpx;
  472. height: 44rpx;
  473. background: #F4F5F7;
  474. border-radius: 0px 6rpx 6rpx 0px;
  475. text-align: center;
  476. line-height: 44rpx;
  477. font-size: 32rpx;
  478. color: #999999;
  479. }
  480. .goodsnum{
  481. width: 88rpx;
  482. height: 44rpx;
  483. background: #F4F5F7;
  484. line-height: 44rpx;
  485. text-align: center;
  486. font-weight: 500;
  487. color: #333333;
  488. font-size: 24rpx;
  489. margin: 0 4rpx;
  490. }
  491. .goodsBottom{
  492. display: flex;
  493. justify-content: space-between;
  494. padding-top: 60rpx;
  495. }
  496. .goodsPrice{
  497. color: #333333;
  498. font-size: 32rpx;
  499. font-weight: 500;
  500. }
  501. .goodsPrice1{
  502. color: #333333;
  503. font-size: 22rpx;
  504. }
  505. .goodsName{
  506. font-weight: 400;
  507. color: #333333;
  508. line-height: 40rpx;
  509. font-size: 28rpx;
  510. height: 80rpx;
  511. text-overflow: -o-ellipsis-lastline;
  512. overflow: hidden;
  513. text-overflow: ellipsis;
  514. display: -webkit-box;
  515. -webkit-line-clamp: 2;
  516. line-clamp: 2;
  517. -webkit-box-orient: vertical;
  518. width: 420rpx;
  519. }
  520. .goodsBoxRgiht{
  521. padding-left: 24rpx;
  522. }
  523. </style>