confirm.vue 12 KB

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