confirm.vue 12 KB

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