You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

product-detail.vue 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <navBar title="产品详情"></navBar>
  3. <navBgCar></navBgCar>
  4. <view class="content-wrap">
  5. <view class="ul-item">
  6. <image
  7. style="width: 100%; height: 170rpx; background-color: #eeeeee"
  8. :src="`${$imgUrl}applyCard/product-bg.png`"
  9. ></image>
  10. <view class="item-value">
  11. <image class="icon-tip" :src="`${$imgUrl}applyCard/wechat.png`"></image>
  12. <view class="content">
  13. <view class="title"> 微信车主服务 </view>
  14. <view style="margin-top: 15rpx" class="tip"> 先通行后付费! </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="value-wrapper">
  19. <view class="flex">
  20. <view class="title"> 产品金额 </view>
  21. <view class="value">
  22. {{ "¥" + state.clientFee }}
  23. </view>
  24. </view>
  25. <view class="flex">
  26. <view class="title"> 加购权益 </view>
  27. <view class="value"> ¥0.00 </view>
  28. </view>
  29. <view class="flex">
  30. <view class="title"> 运费 </view>
  31. <view class="value"> ¥0.00 </view>
  32. </view>
  33. <view class="flex">
  34. <view class="title"> 优惠券 </view>
  35. <view class="value"> 暂无优惠券 </view>
  36. </view>
  37. <view class="flex">
  38. <view class="title"> 积分兑换 </view>
  39. <view class="value"> 暂无积分 </view>
  40. </view>
  41. <view class="flex">
  42. <view class="title"> 实付款 </view>
  43. <view class="money">
  44. {{ "¥" + state.clientFee }}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="action">
  49. <button type="default" class="button" @click="savaHandle()">
  50. {{ "确认办理:¥" + state.clientFee }}
  51. </button>
  52. </view>
  53. </view>
  54. </template>
  55. <script setup lang="ts">
  56. import { onLoad, onShow } from "@dcloudio/uni-app";
  57. import { reactive } from "vue";
  58. import { etcQueryProduct } from "@/utils/network/api.js";
  59. import { request } from "@/utils/network/request.js";
  60. import { stringToJson } from "@/utils/network/encryption";
  61. import { fileURL } from "@/datas/fileURL.js";
  62. import navBgCar from "./components/nav-bg-car5";
  63. import navBar from "../components/nav-bar/nav-bar2.vue";
  64. import { getItem, StorageKeys } from "@/utils/storage.ts";
  65. import {
  66. checkOrderStatus,
  67. orderPay,
  68. wechatAppID,
  69. wechatPayConfigId,
  70. wechatSecret,
  71. } from "@/utils/network/api";
  72. import { confirm, msg } from "@/utils/utils";
  73. const imgURL = `${fileURL}image/`;
  74. const savaHandle = () => {
  75. wxPayment();
  76. };
  77. //获取微信小程序openid
  78. const getOpenID = () => {
  79. uni.login({
  80. provider: "weixin",
  81. success: function (e) {
  82. wx.request({
  83. url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  84. success: (res: any) => {
  85. state.openid = res.data.openid;
  86. // console.log(state.openid);
  87. },
  88. });
  89. },
  90. });
  91. };
  92. //掉起微信支付
  93. const wxPayment = () => {
  94. // #ifdef MP-WEIXIN
  95. const options = {
  96. type: 2,
  97. data: {
  98. openid: state.openid,
  99. productId: state.id,
  100. orderId: state.orderId,
  101. payConfigId: wechatPayConfigId,
  102. },
  103. method: "POST",
  104. showLoading: true,
  105. };
  106. request(orderPay, options).then((res) => {
  107. const data = stringToJson(res.bizContent);
  108. uni.requestPayment({
  109. provider: "wxpay",
  110. orderInfo: "",
  111. timeStamp: data.timestamp,
  112. nonceStr: data.noncestr,
  113. package: data.wxPackage ?? "",
  114. signType: data.signType,
  115. paySign: data.sign,
  116. success: function (e) {
  117. console.log("支付成功", e);
  118. checkOrder();
  119. },
  120. fail: function (err) {
  121. confirm(err, () => {}, "支付失败", false);
  122. },
  123. });
  124. });
  125. // #endif
  126. };
  127. //支付成功改变订单状态
  128. const checkOrder = () => {
  129. const options = {
  130. type: 2,
  131. data: {
  132. orderId: state.orderId,
  133. payConfigId: wechatPayConfigId,
  134. },
  135. method: "POST",
  136. showLoading: true,
  137. };
  138. request(checkOrderStatus, options).then((res) => {
  139. msg("支付成功!");
  140. var pages = getCurrentPages().length;
  141. uni.$emit("refreshOrder");
  142. uni.switchTab({
  143. url:"/pages/order/order"
  144. })
  145. });
  146. };
  147. onLoad((option: any) => {
  148. state.orderId = option.orderId;
  149. state.clientFee = option.clientFee / 100;
  150. state.id = option.id;
  151. getOpenID();
  152. });
  153. const state = reactive({
  154. openid: "",
  155. orderId: "",
  156. clientFee: undefined,
  157. id: "",
  158. });
  159. </script>
  160. <style lang="scss" scoped>
  161. .action {
  162. margin-top: 40rpx;
  163. padding-left: 20rpx;
  164. padding-right: 20rpx;
  165. padding-bottom: 30rpx;
  166. .button {
  167. height: 80rpx;
  168. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  169. border-radius: 40rpx;
  170. font-size: 32rpx;
  171. font-weight: 400;
  172. color: #ffffff;
  173. line-height: 80rpx;
  174. }
  175. }
  176. .value-wrapper {
  177. margin-top: 40rpx;
  178. padding: 0rpx 30rpx;
  179. .flex {
  180. padding: 20rpx 0rpx;
  181. display: flex;
  182. justify-content: space-between;
  183. align-items: center;
  184. .title {
  185. font-size: 28rpx;
  186. font-family: Microsoft YaHei;
  187. font-weight: 400;
  188. color: #777777;
  189. line-height: 28rpx;
  190. }
  191. .value {
  192. font-size: 28rpx;
  193. font-family: Microsoft YaHei;
  194. font-weight: 400;
  195. color: #333333;
  196. line-height: 28rpx;
  197. }
  198. .money {
  199. font-size: 36rpx;
  200. font-family: Microsoft YaHei;
  201. font-weight: 400;
  202. color: #00b38b;
  203. line-height: 36rpx;
  204. }
  205. }
  206. }
  207. .content-wrap {
  208. position: relative;
  209. margin-top: -50rpx;
  210. padding: 0rpx 30rpx;
  211. .ul-item {
  212. padding: 5px 20rpx;
  213. display: flex;
  214. align-items: center;
  215. .item-value {
  216. padding: 20rpx;
  217. position: absolute;
  218. display: flex;
  219. align-items: center;
  220. justify-content: space-around;
  221. .content {
  222. .title {
  223. font-size: 32rpx;
  224. font-family: Microsoft YaHei;
  225. font-weight: 400;
  226. color: #ffffff;
  227. }
  228. .tip {
  229. font-size: 24rpx;
  230. font-family: Microsoft YaHei;
  231. font-weight: 400;
  232. color: #ffffff;
  233. }
  234. }
  235. }
  236. .icon-tip {
  237. width: 100rpx;
  238. height: 100rpx;
  239. }
  240. .content {
  241. margin-left: 40rpx;
  242. }
  243. }
  244. }
  245. </style>