confirm.vue 10 KB

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