confirm.vue 11 KB

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