confirm.vue 12 KB

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