confirm.vue 12 KB

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