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

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