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.

detail.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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 class="price">
  17. ¥<text style="font-size: 40rpx">99</text>.00
  18. </view>
  19. </view>
  20. </view>
  21. <view class="card-box">
  22. <view class="title"> 基础服务 </view>
  23. <view class="item-box">
  24. <view class=""> ETC设备与卡片 </view>
  25. <view class=""> 设备质保一年 </view>
  26. <view class=""> 开具通行费发票 </view>
  27. <view class=""> 高速通行9.5折 </view>
  28. </view>
  29. </view>
  30. <view class="radio">
  31. <view class="title"> 推荐加购权益 </view>
  32. <view class="radio-item">
  33. <image :src="`${$imgUrl}card-bg.png`" mode=""></image>
  34. <view class="radio-box">
  35. <view class="radio-box-left">
  36. <view class="icon">
  37. <image :src="`${$imgUrl}park.png`" mode=""></image>
  38. </view>
  39. <view class="content">
  40. <view class=""> 64元停车券 </view>
  41. <text>¥44.00</text>
  42. </view>
  43. </view>
  44. <view class="choose-item" @click="flag = 1">
  45. <view class="active" v-if="flag == 1"> </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="radio-item">
  50. <image :src="`${$imgUrl}card-bg.png`" mode=""></image>
  51. <view class="radio-box">
  52. <view class="radio-box-left">
  53. <view class="icon">
  54. <image :src="`${$imgUrl}car1.png`" mode=""></image>
  55. </view>
  56. <view class="content">
  57. <view class=""> 10次洗车券 </view>
  58. <text>¥44.00</text>
  59. </view>
  60. </view>
  61. <view class="choose-item" @click="flag = 2">
  62. <view class="active" v-if="flag == 2"> </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view class="more-btn">
  67. 查看更多<u-icon name="arrow-down"></u-icon>
  68. </view>
  69. </view>
  70. <view class="value-wrapper">
  71. <view class="flex">
  72. <view class="title"> 产品金额 </view>
  73. <view class="value">
  74. {{ "¥" + state.clientFee }}
  75. </view>
  76. </view>
  77. <view class="flex">
  78. <view class="title"> 加购权益 </view>
  79. <view class="value"> ¥0.00 </view>
  80. </view>
  81. <view class="flex">
  82. <view class="title"> 运费 </view>
  83. <view class="value"> ¥0.00 </view>
  84. </view>
  85. <view class="flex">
  86. <view class="title"> 优惠券 </view>
  87. <view class="value"> 暂无优惠券 </view>
  88. </view>
  89. <view class="flex">
  90. <view class="title"> 积分兑换 </view>
  91. <view class="value"> 暂无积分 </view>
  92. </view>
  93. <view class="flex">
  94. <view class="title"> 实付款 </view>
  95. <view class="money">
  96. {{ "¥" + state.clientFee }}
  97. </view>
  98. </view>
  99. </view>
  100. <view class="footer">
  101. <u-radio-group v-model="value">
  102. <u-radio shape="square">
  103. 阅读并同意<text>《用户授权协议》</text><text>《XXX隐私协议》</text>
  104. </u-radio>
  105. </u-radio-group>
  106. </view>
  107. <view class="action">
  108. <button type="default" class="button" @click="savaHandle()">
  109. {{ "确认办理:¥" + state.clientFee }}
  110. </button>
  111. </view>
  112. </view>
  113. </template>
  114. <script setup lang="ts">
  115. import { onLoad, onShow } from "@dcloudio/uni-app";
  116. import { reactive, ref } from "vue";
  117. import { etcQueryProduct } from "@/utils/network/api.js";
  118. import { request } from "@/utils/network/request.js";
  119. import { stringToJson } from "@/utils/network/encryption";
  120. import { fileURL } from "@/datas/fileURL.js";
  121. // import navBgCar from "./components/nav-bg-car5";
  122. // import navBar from "../../components/nav-bar/nav-bar2.vue"
  123. import { getItem, StorageKeys } from "@/utils/storage.ts";
  124. import {
  125. checkOrderStatus,
  126. orderPay,
  127. wechatAppID,
  128. wechatPayConfigId,
  129. wechatSecret,
  130. } from "@/utils/network/api";
  131. import { confirm, msg } from "@/utils/utils";
  132. const imgURL = `${fileURL}image/`;
  133. const flag = ref(1);
  134. const savaHandle = () => {
  135. // wxPayment()
  136. uni.redirectTo({
  137. url: "/subpackage/after-sale/to-bookkeeping-card/result",
  138. });
  139. };
  140. //获取微信小程序openid
  141. const getOpenID = () => {
  142. uni.login({
  143. provider: "weixin",
  144. success: function (e) {
  145. uni.request({
  146. url: `https://api.weixin.qq.com/sns/jscode2session?appid=${wechatAppID}&secret=${wechatSecret}&js_code=${e.code}&grant_type=authorization_code`,
  147. success: (res: any) => {
  148. state.openid = res.data.openid;
  149. // console.log(state.openid);
  150. },
  151. });
  152. },
  153. });
  154. };
  155. //掉起微信支付
  156. const wxPayment = () => {
  157. // #ifdef MP-WEIXIN
  158. const options = {
  159. type: 2,
  160. data: {
  161. openid: state.openid,
  162. productId: "027af827c70140d1ab4c68940f4793f2", //TODO 后端给的,用于调试测试
  163. orderId: state.orderId,
  164. payConfigId: wechatPayConfigId,
  165. },
  166. method: "POST",
  167. showLoading: true,
  168. };
  169. request(orderPay, options).then((res) => {
  170. const data = stringToJson(res.bizContent);
  171. uni.requestPayment({
  172. provider: "wxpay",
  173. orderInfo: "",
  174. timeStamp: data.timestamp,
  175. nonceStr: data.noncestr,
  176. package: data.wxPackage ?data.wxPackage: "",
  177. signType: data.signType,
  178. paySign: data.sign,
  179. success: function (e) {
  180. console.log("支付成功", e);
  181. checkOrder();
  182. },
  183. fail: function (err) {
  184. confirm(err, () => {}, "支付失败", false);
  185. },
  186. });
  187. });
  188. // #endif
  189. };
  190. //支付成功改变订单状态
  191. const checkOrder = () => {
  192. const options = {
  193. type: 2,
  194. data: {
  195. orderId: state.orderId,
  196. payConfigId: wechatPayConfigId,
  197. },
  198. method: "POST",
  199. showLoading: true,
  200. };
  201. request(checkOrderStatus, options).then((res) => {
  202. msg("支付成功!");
  203. var pages = getCurrentPages().length;
  204. uni.navigateBack({
  205. delta: pages,
  206. });
  207. });
  208. };
  209. onLoad((option: any) => {
  210. state.orderId = option.orderId;
  211. state.clientFee = option.clientFee / 100;
  212. getOpenID();
  213. });
  214. const state = reactive({
  215. openid: "",
  216. orderId: "",
  217. clientFee: undefined,
  218. });
  219. </script>
  220. <style lang="scss" scoped>
  221. .action {
  222. margin-top: 40rpx;
  223. padding-left: 20rpx;
  224. padding-right: 20rpx;
  225. padding-bottom: 30rpx;
  226. .button {
  227. height: 80rpx;
  228. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  229. border-radius: 40rpx;
  230. font-size: 32rpx;
  231. font-weight: 400;
  232. color: #ffffff;
  233. line-height: 80rpx;
  234. }
  235. }
  236. .footer {
  237. margin-top: 45rpx;
  238. text {
  239. color: #00b38b;
  240. }
  241. }
  242. .value-wrapper {
  243. margin-top: 40rpx;
  244. padding: 0rpx 30rpx;
  245. border-bottom: 1rpx solid #dcdcdc;
  246. .flex {
  247. padding: 20rpx 0rpx;
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. .title {
  252. font-size: 28rpx;
  253. font-family: Microsoft YaHei;
  254. font-weight: 400;
  255. color: #777777;
  256. line-height: 28rpx;
  257. }
  258. .value {
  259. font-size: 28rpx;
  260. font-family: Microsoft YaHei;
  261. font-weight: 400;
  262. color: #333333;
  263. line-height: 28rpx;
  264. }
  265. .money {
  266. font-size: 36rpx;
  267. font-family: Microsoft YaHei;
  268. font-weight: 400;
  269. color: #00b38b;
  270. line-height: 36rpx;
  271. }
  272. }
  273. }
  274. .content-wrap {
  275. position: relative;
  276. padding: 0rpx 30rpx;
  277. .ul-item {
  278. padding: 5px 0rpx;
  279. display: flex;
  280. align-items: center;
  281. .item-value {
  282. padding: 20rpx;
  283. position: absolute;
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-around;
  287. .content {
  288. .title {
  289. font-size: 32rpx;
  290. font-family: Microsoft YaHei;
  291. font-weight: 400;
  292. color: #ffffff;
  293. }
  294. .tip {
  295. font-size: 24rpx;
  296. font-family: Microsoft YaHei;
  297. font-weight: 400;
  298. color: #ffffff;
  299. }
  300. }
  301. .price {
  302. margin-left: 180rpx;
  303. font-size: 25rpx;
  304. font-family: Microsoft YaHei;
  305. font-weight: 400;
  306. color: #ffffff;
  307. }
  308. }
  309. .icon-tip {
  310. width: 100rpx;
  311. height: 100rpx;
  312. }
  313. .content {
  314. margin-left: 40rpx;
  315. }
  316. }
  317. .card-box {
  318. .title {
  319. font-size: 30rpx;
  320. font-family: Microsoft YaHei;
  321. font-weight: 400;
  322. color: #333333;
  323. margin: 30rpx 0;
  324. }
  325. .item-box {
  326. display: flex;
  327. flex-wrap: wrap;
  328. view {
  329. background: #c1ffed;
  330. border: 1px solid #00b38b;
  331. border-radius: 30rpx;
  332. padding: 5rpx 15rpx;
  333. font-size: 28rpx;
  334. font-family: Microsoft YaHei;
  335. font-weight: 400;
  336. color: #019977;
  337. margin: 20rpx 30rpx;
  338. margin-top: 0;
  339. }
  340. }
  341. }
  342. .radio {
  343. .title {
  344. font-size: 30rpx;
  345. font-family: Microsoft YaHei;
  346. font-weight: 400;
  347. color: #333333;
  348. margin: 30rpx 0;
  349. }
  350. .more-btn {
  351. text-align: center;
  352. margin-top: 30rpx;
  353. border-bottom: 1rpx solid #dcdcdc;
  354. padding-bottom: 30rpx;
  355. font-size: 26rpx;
  356. font-family: Microsoft YaHei;
  357. font-weight: 400;
  358. color: #999999;
  359. }
  360. .radio-item {
  361. width: 100%;
  362. height: 150rpx;
  363. position: relative;
  364. image {
  365. width: 100%;
  366. height: 100%;
  367. position: absolute;
  368. z-index: -1;
  369. }
  370. .radio-box {
  371. // width: 100%;
  372. // height: 100%;
  373. display: flex;
  374. justify-content: space-between;
  375. align-items: center;
  376. padding: 30rpx;
  377. margin: 30rpx 0;
  378. .radio-box-left {
  379. display: flex;
  380. .icon {
  381. width: 88rpx;
  382. height: 88rpx;
  383. background: #89fcdb;
  384. border-radius: 50%;
  385. display: flex;
  386. justify-content: center;
  387. align-items: center;
  388. image {
  389. width: 48rpx;
  390. height: 48rpx;
  391. z-index: 1;
  392. }
  393. }
  394. .content {
  395. margin-left: 64rpx;
  396. view {
  397. font-size: 28rpx;
  398. font-family: Microsoft YaHei;
  399. font-weight: 400;
  400. color: #333333;
  401. margin-bottom: 10rpx;
  402. }
  403. text {
  404. font-size: 36rpx;
  405. font-family: Microsoft YaHei;
  406. font-weight: 400;
  407. color: #333333;
  408. }
  409. }
  410. }
  411. .choose-item {
  412. width: 44rpx;
  413. height: 44rpx;
  414. border: 2px solid #00b38b;
  415. border-radius: 50%;
  416. display: flex;
  417. justify-content: center;
  418. align-items: center;
  419. .active {
  420. width: 34rpx;
  421. height: 34rpx;
  422. background: #00b38b;
  423. border-radius: 50%;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. }
  430. </style>