confirm.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view>
  3. <view v-if="pageLoad">
  4. <view class="goods-info" v-if="goodsData">
  5. <view class="poi-info">
  6. <view class="img"></view>
  7. <view class="name">{{ storeData.poi_name }}</view>
  8. </view>
  9. <view class="goods-body">
  10. <view class="img"><image :src="orderData.img" mode="widthFix"></image></view>
  11. <view class="body-info">
  12. <view class="goods-name">{{ goodsData.product_name }}</view>
  13. <view class="price">
  14. <view class="price-left">
  15. <view class="pay-price">{{$dialog.formatMoney(orderData.price,true)}}</view>
  16. <view class="line-price">{{$dialog.formatMoney(orderData.line_price,true)}}</view>
  17. <view class="sale">{{$dialog.disFormat(orderData.price,orderData.line_price)}}折</view>
  18. </view>
  19. <view class="price-right">x {{orderData.number}}</view>
  20. </view>
  21. <view class="goods-safe">
  22. <view class="safe-item"><image src="/static/image/check.png"></image>过期退</view>
  23. <view class="safe-item"><image src="/static/image/check.png"></image>随时退</view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="order-mobile">
  29. <view class="name">联系方式(选填)</view>
  30. <view class="mobile-input">
  31. <view class="input-left">
  32. <input type="number" v-model="mobile" class="input" placeholder="输入手机号码(仅限于商家确认)" />
  33. </view>
  34. <view class="input-right"><button type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" size="mini">一键填写</button></view>
  35. </view>
  36. </view>
  37. <view class="order-buy-read" @click="openRule(1)">
  38. <view class="name">购买须知</view>
  39. <view class="right"><image src="/static/image/right-black.png"></image></view>
  40. </view>
  41. <view class="order-pay-btn" v-if="orderData">
  42. <view class="pay-group">
  43. <view class="pay-money">
  44. <text>实付</text>
  45. {{orderData?$dialog.formatMoney(orderData.price,true):'0.00'}}
  46. </view>
  47. <view class="pay-btn">
  48. {{orderData.life_goods_id}}
  49. <pay-button-sdk
  50. :mode="2"
  51. :goods-type="2"
  52. :goods-id="orderData.life_goods_id"
  53. :order-id="orderData.order_sn"
  54. bind:getgoodsinfo="getGoodsInfo"
  55. bind:placeorder="userLogin"
  56. bind:error="onErrors"
  57. bind:pay="onPay"
  58. ></pay-button-sdk>
  59. </view>
  60. </view>
  61. <!-- <button type="primary" :disabled="disabled" @click="payOrder">立即支付 </button> -->
  62. <view class="safe-height"></view>
  63. </view>
  64. </view>
  65. <view class="" v-else>
  66. <view class="skeleton">
  67. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  68. <view class="skeleton-line animate"></view>
  69. <view class="skeleton-line min animate"></view>
  70. <view class="skeleton-line min animate"></view>
  71. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  72. <view class="skeleton-line max animate" style="height: 200upx;"></view>
  73. </view>
  74. </view>
  75. <uni-popup ref="rulepopup" type="bottom" border-radius="10px 10px 0 0" background-color="#ffffff">
  76. <view class="service-popup popup-height" v-if="goodsData">
  77. <view class="title" @click="openRule(2)">购买须知 <view class="close"><image src="/static/image/close.png"></image></view></view>
  78. <view class="rule-list">
  79. <view class="rule-item">
  80. <view class="icon"><image src="/static/image/rule-date.png"></image></view>
  81. <view class="item-top">
  82. <view class="name">可用日期</view>
  83. <view class="desc">
  84. <span class="mix-item" v-if="goodsData.use_date_type==1">
  85. 自购买之日起{{ goodsData.day_duration }}天有效
  86. </span>
  87. <span class="mix-item" v-if="goodsData.use_date_type==2">
  88. 有效期:{{ $dialog.dateFormat(goodsData.use_time_start,'yyyy-MM-dd') }}至{{ $dialog.dateFormat(goodsData.use_time_end,'yyyy-MM-dd') }}
  89. </span>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="rule-item">
  94. <view class="icon"><image src="/static/image/rule-time.png"></image></view>
  95. <view class="item-top">
  96. <view class="name">可用时间</view>
  97. <view class="desc" v-if="goodsData.can_no_use_date==1">商家营业时间可用</view>
  98. </view>
  99. </view>
  100. <view class="rule-item">
  101. <view class="icon"><image src="/static/image/rule-rule.png"></image></view>
  102. <view class="item-top">
  103. <view class="name">预约规则</view>
  104. <view class="desc" v-if="goodsData.booking_type==1">无需预约,高峰期可能需要排队</view>
  105. <view class="desc" v-if="goodsData.booking_type==2">
  106. 需要提前<span>{{ goodsData.booking_date }}</span>{{ goodsData.booking_unit==1?'天':'小时' }}预约
  107. </view>
  108. </view>
  109. </view>
  110. <view class="rule-item">
  111. <view class="icon"><image src="/static/image/rule-refund.png"></image></view>
  112. <view class="item-top">
  113. <view class="name">退款政策<view class="tips">随时退/过期退</view></view>
  114. <view class="desc">随时退款:未核销的商品支持随时申请退款;过期自动退:商品若在有效时间内未核销使用,到期之后系统将自动发起退款</view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </uni-popup>
  120. </view>
  121. </template>
  122. <script>
  123. var app;
  124. import * as Api from "@/static/api/order.js";
  125. var loadingPayBtn = false
  126. export default {
  127. data() {
  128. return {
  129. pageLoad:true,
  130. orderData:null,
  131. goodsData:null,
  132. storeData:null,
  133. orderSn:"",
  134. mobile:"",
  135. loadingPayBtn:0
  136. }
  137. },
  138. onLoad({order}) {
  139. app = this;
  140. app.orderSn = order;
  141. app.getOrderDetail()
  142. },
  143. created() {
  144. this.$scope.getGoodsInfo = this.getGoodsInfo;
  145. this.$scope.userLogin = this.userLogin;
  146. this.$scope.onErrors = this.onErrors;
  147. this.$scope.onPay = this.onPay;
  148. },
  149. methods: {
  150. getPhoneNumber(e){
  151. var detail = e.detail;
  152. Api.mobile(detail).then((res)=>{
  153. if (res.code == 0) {
  154. return app.$dialog.showSuccess(res.msg)
  155. }
  156. app.mobile = res.data.mobile;
  157. })
  158. },
  159. openRule(type){
  160. if (type == 1) {
  161. app.$refs.rulepopup.open()
  162. } else {
  163. app.$refs.rulepopup.close()
  164. }
  165. },
  166. onErrors(e){
  167. console.log("错误",e)
  168. if (app.loadingPayBtn == 1) {
  169. // app.payOrder()
  170. return ;
  171. }
  172. loadingPayBtn ++;
  173. },
  174. getGoodsInfo(event){
  175. console.log("getGoodsInfo",event)
  176. const { goodsId } = event.detail;
  177. // return new Promise(resolve => {
  178. // // 在此处开发者可以进行商品数据请求,获取商品信息
  179. // // 然后将商品信息传入 resolve 函数
  180. // resolve({
  181. // minLimits: 1,
  182. // maxLimits: 2,
  183. // dateRule: '周一至周日可用',
  184. // relationType: 1,
  185. // validation: {
  186. // phoneNumber: {
  187. // required: true // 手机号是否必填
  188. // }
  189. // },
  190. // // 在 bind:getgoodsinfo 返回的 promise 的 resolve 函数中新增 marketingVersion 字段
  191. // marketingVersion: 2,
  192. // });
  193. // })
  194. return new Promise(resolve => {
  195. resolve({
  196. currentPrice: parseInt(app.orderData.price),
  197. goodsName: app.goodsData.product_name,
  198. goodsPhoto: app.goodsData.image_list[0].url,
  199. goodsLabels: [
  200. {type: 'EXPIRED_RETURNS'}, // 过期退
  201. {type: 'REFUND_ANYTIME'}, // 随时退
  202. ],
  203. minLimits: 1,
  204. maxLimits: 2,
  205. dateRule: '周一至周日可用',
  206. relationType: 1,
  207. validation: {
  208. phoneNumber: {
  209. required: false // 手机号是否必填, 为 true则必填,false选填,默认选填
  210. }
  211. },
  212. extra: {},
  213. tradeOption:{
  214. life_trade_flag :1, // 0:非融合链路(默认值) 1:走融合链路(标准融合/完全融合)
  215. is_use_tag:false // 泛知识是否接入交易规则,true:接入 false:不接入(默认值)
  216. },
  217. // 在 bind:getgoodsinfo 返回的 promise 的 resolve 函数中新增 marketingVersion 字段
  218. marketingVersion: 2,
  219. });
  220. });
  221. },
  222. userLogin(event) {
  223. console.log("userLogin",event)
  224. return new Promise((resolve, reject) => {
  225. tt.login({
  226. success(e){
  227. console.log("登录成功",e)
  228. resolve()
  229. },
  230. fail: () => reject()
  231. });
  232. });
  233. },
  234. onPay(event){
  235. console.log("onpay",event)
  236. const { status, outOrderNo, result } = event.detail;
  237. console.log(status, outOrderNo, result)
  238. if (status === 'success') {
  239. const { code } = result;
  240. if (code === 0) {
  241. // 继续支付成功
  242. } else {
  243. // 继续支付失败(超时、取消、关闭)
  244. }
  245. } else {}
  246. },
  247. payOrder(){
  248. Api.toPay({order:app.orderSn,mobile:app.mobile}).then((res)=>{
  249. if (res.code == 0) {
  250. return app.$dialog.showSuccess(res.msg)
  251. }
  252. uni.requestPayment({
  253. orderInfo:res.data.pay,
  254. service:5,
  255. success(resp){
  256. if (resp.code == 0) { // res.code=0时,才表示支付成功
  257. app.$dialog.showSuccess("支付成功","none",function(){
  258. uni.navigateTo({
  259. url:"/pages/order/detail?order="+app.orderSn
  260. })
  261. });
  262. }
  263. },
  264. fail(resp) {
  265. app.$dialog.showSuccess("支付失败,可再次重试","none",function(){
  266. uni.navigateTo({
  267. url:"/pages/order/detail?order="+app.orderSn
  268. })
  269. });
  270. }
  271. })
  272. })
  273. },
  274. getOrderDetail(){
  275. app.pageLoad = false
  276. Api.confirm({order:app.orderSn}).then((res)=>{
  277. app.pageLoad = true
  278. if (res.code && res.code == 0) {
  279. return app.$dialog.showSuccess(res.msg)
  280. }
  281. app.orderData = res.data;
  282. app.goodsData = res.data.product;
  283. app.storeData = res.data.poi;
  284. })
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. page{background-color: #f8f8f8;}
  291. .order-mobile{margin-top: 20upx;padding: 0 20upx;background-color: #fff;}
  292. .order-mobile .name{padding: 20upx 0;font-size: 28upx;color: #333;font-weight: bold;border-bottom: 2upx solid #f8f8f8;}
  293. .order-mobile .mobile-input{padding: 20upx 0;display: flex;align-items: center;justify-content: space-between;gap: 20upx;}
  294. .order-mobile .mobile-input .input-left{flex: 1;}
  295. .order-mobile .mobile-input .input-left .input{font-size: 24upx;width: 100%;}
  296. .order-buy-read{background-color: #fff;margin-top: 20upx;padding: 20upx;display: flex;align-items: center;justify-content: space-between;font-size: 28upx;}
  297. .order-buy-read .right image{width: 40upx;height: 40upx;}
  298. .order-pay-btn{
  299. background-color: #fff;
  300. padding: 20upx;
  301. position: fixed;
  302. bottom: 0;
  303. left: 0;
  304. right: 0;
  305. .safe-height{
  306. height: env(safe-area-inset-bottom);
  307. width: 100%;
  308. background-color: #fff;
  309. }
  310. .pay-group{
  311. display: flex;
  312. align-items: center;
  313. justify-content: space-between;
  314. .pay-money{
  315. font-size: 32upx;
  316. color: #f00;
  317. font-weight: bold;
  318. text{
  319. font-size: 24upx;
  320. font-weight: normal;
  321. color: #666;
  322. }
  323. }
  324. }
  325. }
  326. .goods-info{background-color: #fff;padding: 0 20upx;margin-top: 20upx;}
  327. .goods-info .poi-info{display: flex;align-items: center;font-size: 28upx;color: #666;padding: 20upx 0;border-bottom: 2upx solid #f8f8f8;}
  328. .goods-info .goods-safe{display: flex;align-items: center;font-size: 24rpx;color: #999;gap: 40upx;}
  329. .goods-info .goods-safe .safe-item{display: flex;align-items: center;}
  330. .goods-info .goods-safe image{width: 30upx;height: 30upx;margin-right: 10upx;}
  331. .goods-body{padding: 20upx 0;display: flex;align-items: flex-start;}
  332. .goods-body .img{height: 200upx;overflow: hidden;}
  333. .goods-body .img image{width: 200upx;border-radius: 10upx;}
  334. .goods-body .body-info{flex: 1;margin-left: 20upx;}
  335. .goods-body .goods-name{font-size: 28upx;display: -webkit-box;-webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;}
  336. .goods-body .price{display: flex;align-items: center;margin: 20upx 0;}
  337. .goods-body .price .price-left{display: flex;align-items: center;}
  338. .goods-body .price .pay-price{color: #FF4747;font-size: 32rpx;font-weight: bold;margin-right: 10upx;}
  339. .goods-body .price .line-price{color: #999999;font-size: 22rpx;text-decoration-line: line-through;margin-right: 10upx;}
  340. .goods-body .price .sale{background-color: #FDEBE5;border: 4rpx;font-size: 22rpx;color: #FF4747;padding: 10rpx;}
  341. .goods-body .price .price-right{margin-left: auto;margin-right: 20upx;font-size: 24upx;padding: 10upx;color: #666;}
  342. .service-popup.popup-height{height: 60vh;}
  343. .service-popup.popup-white{background-color: #fff;margin-top: 20upx;}
  344. .service-popup.popup-white .title{border-bottom: 2upx solid #f8f8f8;}
  345. .service-popup .title{line-height: 80upx;font-size: 32rpx;color: #333;font-weight: bold;padding: 0 20upx;display: flex;align-items: center;}
  346. .service-popup .title .close{margin-left: auto;margin-right: 0;display: flex;align-items: center;justify-content: center;}
  347. .service-popup .title .close image{width: 40upx;height: 40upx;}
  348. .service-popup.popup-white .rule-list{padding-bottom: 20upx;}
  349. .service-popup .rule-item{display: flex;margin-top: 40upx;align-items: start;padding: 0 20upx;}
  350. .service-popup .rule-item image{width: 50upx;height: 50upx;}
  351. .service-popup .rule-item .item-top{margin-left: 20upx;}
  352. .service-popup .rule-item .name{font-size: 28rpx;color: #333;font-weight: bold;margin-bottom: 10upx;display: flex;align-items: center;}
  353. .service-popup .rule-item .name .tips{color: #333;border: 2upx solid #ddd;border-radius: 5upx;font-size: 22rpx;font-weight: normal;margin-left: 40upx;background-color: #fff;padding: 5upx 10upx;}
  354. .service-popup .rule-item .desc{color: #999;font-size: 24rpx;line-height: 40upx;}
  355. </style>