tencent.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. <template>
  2. <view class="app-container" flex column>
  3. <view :class="['header', orderList.length > 0 ? 'header-bg' : '']">
  4. <view class="info" flex>
  5. <view class="dev-img" flex center>
  6. <img :src="info.devicePic" />
  7. </view>
  8. <view class="dev" flex column>
  9. <view class="dev-name owt">{{ info.deviceName }}</view>
  10. <view class="dev-history" @click="getRouter"
  11. >开通记录
  12. <uni-icons type="right" color="#9fa5ad" size="11" />
  13. </view>
  14. </view>
  15. </view>
  16. <view class="progress" flex column center>
  17. <progress
  18. :percent="percent"
  19. activeColor="#FFD5A0"
  20. backgroundColor="#746C64"
  21. border-radius="20"
  22. />
  23. <view class="progress-info" flex between>
  24. <view>
  25. <text
  26. >剩余:{{ (this.rateplan.left / 1024).toFixed(2) }}GB / 总量:{{
  27. (this.rateplan.total / 1024).toFixed(2)
  28. }}GB
  29. </text>
  30. <text style="margin-left: 10px">{{ this.rateplan.dayStr }}</text>
  31. </view>
  32. <text>已用:{{ (this.rateplan.used / 1024).toFixed(2) }}GB</text>
  33. </view>
  34. </view>
  35. <view v-if="orderList.length > 0">
  36. <view
  37. class="progress"
  38. flex
  39. column
  40. center
  41. v-for="item in orderList"
  42. :key="item.orderId"
  43. >
  44. <progress
  45. activeColor="#FFD5A0"
  46. backgroundColor="#746C64"
  47. border-radius="20"
  48. />
  49. <view class="progress-info" flex>
  50. <view>
  51. <text>待生效流量套餐</text>
  52. <text style="margin-left: 10px"
  53. >总量:{{ (item.total / 1024 / 1024).toFixed(2) }}GB</text
  54. >
  55. </view>
  56. <text style="margin-left: 10px">{{ item.dayStr }}</text>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="main">
  62. <!-- <button class="button popup-success" @click="getNewAcitivityDetail()">-->
  63. <!-- <text-->
  64. <!-- class="button-text success-text">领取福利-->
  65. <!-- </text>-->
  66. <!-- </button>-->
  67. <view class="title" flex>
  68. <text>流量选择</text>
  69. <uni-icons
  70. type="help"
  71. color="#828282"
  72. style="margin-left: 4px"
  73. @click="getOpen"
  74. />
  75. </view>
  76. <view flex wrap>
  77. <view
  78. :class="['list', active === index ? 'active' : '']"
  79. v-for="(item, index) in options"
  80. :key="index"
  81. flex
  82. column
  83. between
  84. @click="getActive(item, index)"
  85. :data-content-before="item.operators"
  86. >
  87. <view class="flow owt">{{ item.name }}</view>
  88. <view class="discount icon">{{ item.goodDiscountedPrice }}</view>
  89. <view class="price icon">{{ item.goodPrice }}</view>
  90. <view v-if="item.tagName" class="tag-name">{{ item.tagName }}</view>
  91. </view>
  92. </view>
  93. <view class="explain" flex column>
  94. <text>说明:</text>
  95. <text>1、当前流量包购买后,将充值至猫王音响赠送的SIM卡内</text>
  96. <text
  97. >2、预充值流量因运营商结算时效,上一个流量包使用完后1小时
  98. 内生效,如有疑问,请咨询客服。</text
  99. >
  100. <text>3、如在有效期内流量未使用完毕,流量将被清零</text>
  101. </view>
  102. </view>
  103. <view class="footer">
  104. <view class="warning">
  105. 开通后仅支持在当前绑定的猫王音响上通过移动数据模式使用,不支持蓝牙模式
  106. </view>
  107. <button @click="getWechatPay">立即购买</button>
  108. </view>
  109. <!-- 弹窗 -->
  110. <uni-popup
  111. ref="popup"
  112. type="bottom"
  113. border-radius="10px 10px 10px 10px"
  114. background-color="#2a2a2a"
  115. >
  116. <view class="popup">
  117. <view class="title">购买须知</view>
  118. <view class="content">
  119. <h4>
  120. 1.
  121. 支付完成后,若当前没有生效中的套餐,套餐立即生效,若当前有生效中未使用完套餐,购买套餐进入流量套餐队列,待上一个套餐失效后激活生效。
  122. </h4>
  123. <h4>2. 此卡充值流量套餐后,仅限当前设备使用。</h4>
  124. <h4>3. 此套餐为虚拟产品,购买后不支持退款。</h4>
  125. <h4>
  126. 4. 客服微信:miao friend
  127. ,有任何问题请添加客服微信,我们将耐心为您解决问题。
  128. </h4>
  129. </view>
  130. <button @click="getClose">我知道了</button>
  131. </view>
  132. </uni-popup>
  133. <view>
  134. <!-- 提示窗示例 -->
  135. <uni-popup ref="alertDialog" type="dialog">
  136. <uni-popup-dialog
  137. :showClose="showClose"
  138. :type="msgType"
  139. cancelText="不领取"
  140. confirmText="领取"
  141. title="福利通知"
  142. content="您当前有一个流量领取福利!"
  143. @confirm="dialogConfirm"
  144. @close="dialogClose"
  145. ></uni-popup-dialog>
  146. </uni-popup>
  147. </view>
  148. <view>
  149. <!-- 提示信息弹窗 -->
  150. <uni-popup ref="message" type="message">
  151. <uni-popup-message
  152. :type="msgType"
  153. :message="messageText"
  154. :duration="2000"
  155. ></uni-popup-message>
  156. </uni-popup>
  157. </view>
  158. </view>
  159. </template>
  160. <script>
  161. import {
  162. detail,
  163. newAcitivityDetail,
  164. openId,
  165. options,
  166. order,
  167. wechatPay,
  168. } from "@/api/pay";
  169. export default {
  170. data() {
  171. return {
  172. isWeixin: false,
  173. type: "center",
  174. msgType: "success",
  175. messageText: "这是一条成功提示",
  176. value: "",
  177. showClose: false,
  178. // 流量信息
  179. info: {},
  180. rateplan: {},
  181. // 已用流量
  182. percent: 0,
  183. // 下单表单
  184. form: {},
  185. // 流量选择
  186. options: [],
  187. // 选择
  188. active: 0,
  189. // 流量套餐id
  190. goddsId: 0,
  191. state: "",
  192. // 待生效流量
  193. orderList: [],
  194. isReceive: false,
  195. description: "",
  196. id: "",
  197. name: "",
  198. pic: "",
  199. };
  200. },
  201. onLoad(e) {
  202. // this.detectWeixin();
  203. // if (!this.isWeixin){
  204. // // 跳转到微信页面
  205. // uni.navigateTo({
  206. // url: `/pages/weixin/index`,
  207. // });
  208. // }
  209. this.state = e.state;
  210. this.getOpenId(e);
  211. this.getDetail();
  212. this.getOptions();
  213. this.getOrder();
  214. this.getNewAcitivityDetail();
  215. },
  216. methods: {
  217. // detectWeixin() {
  218. // let userAgent = navigator.userAgent;
  219. // if (userAgent.includes("MicroMessenger")) {
  220. // this.isWeixin = true
  221. // } else {
  222. // this.isWeixin = false
  223. // }
  224. // },
  225. // 联通流量详细信息
  226. getNewAcitivityDetail() {
  227. newAcitivityDetail({
  228. state: this.state,
  229. }).then((res) => {
  230. console.log("asdfqwerqrqr====" + JSON.stringify(res));
  231. if (res.code === 0) {
  232. this.isReceive = res.data.isReceive;
  233. this.id = res.data.id;
  234. this.name = res.data.name;
  235. this.pic = res.data.pic;
  236. this.description = res.data.description;
  237. // 可以领取
  238. if (res.data.isReceive) {
  239. this.msgType = "success";
  240. this.$refs.alertDialog.open();
  241. } else {
  242. // uni.showToast({
  243. // title: res.data.msg,
  244. // icon: "none",
  245. // mask: true,
  246. // duration: 4000,
  247. // });
  248. }
  249. } else {
  250. // uni.showToast({
  251. // title: res.message,
  252. // icon: "none",
  253. // mask: true,
  254. // duration: 4000,
  255. // });
  256. }
  257. });
  258. },
  259. dialogConfirm() {
  260. this.messageText = `点击确认了 ${this.msgType} 窗口`;
  261. this.$refs.alertDialog.close();
  262. // 跳转到活动页面
  263. uni.navigateTo({
  264. url: `/pages/activity/new?state=${this.state}&id=${this.id}&pic=${this.pic}`,
  265. });
  266. },
  267. dialogClose() {
  268. // alert("关闭")
  269. },
  270. // 获取openId
  271. getOpenId(e) {
  272. openId(e.code).then((res) => {
  273. if (res.code === 0) {
  274. uni.setStorageSync("openId", res.data.openid);
  275. }
  276. });
  277. },
  278. // 流量信息
  279. getDetail() {
  280. detail({ state: this.state }).then((res) => {
  281. if (res.code === 0) {
  282. this.info = res.data;
  283. this.rateplan = res.data.rateplan;
  284. this.percent = (this.rateplan.used / this.rateplan.total) * 100;
  285. }
  286. });
  287. },
  288. // 流量列表
  289. getOrder() {
  290. order({ state: this.state }).then((res) => {
  291. if (res.code === 0) {
  292. this.orderList = res.data.filter((i) => i.status === 1).splice(0, 2);
  293. }
  294. });
  295. },
  296. // 流量套餐
  297. getOptions() {
  298. options({ state: this.state }).then((res) => {
  299. this.options = res.data;
  300. this.goodsId = res.data[0].id;
  301. res.data.map((i) =>
  302. document.documentElement.style.setProperty("——operators", i.operators)
  303. );
  304. });
  305. },
  306. // 选择套餐
  307. getActive(item, index) {
  308. this.active = index;
  309. this.goodsId = item.id;
  310. },
  311. // 下单
  312. getWechatPay() {
  313. wechatPay({
  314. openId: uni.getStorageSync("openId"),
  315. goodType: 18,
  316. goodsId: this.goodsId,
  317. ptype: 1,
  318. state: this.state,
  319. tradeType: 2,
  320. }).then((res) => {
  321. if (res.code === 0) {
  322. this.form = JSON.parse(res.data.wxOrder.formUrl);
  323. if (typeof WeixinJSBridge == "undefined") {
  324. if (document.addEventListener) {
  325. document.addEventListener(
  326. "WeixinJSBridge",
  327. this.onBridgeReady(),
  328. false
  329. );
  330. } else if (document.attachEvent) {
  331. document.attachEvent("WeixinJSBridge", this.onBridgeReady());
  332. document.attachEvent(
  333. "onWeixinJSBridgeReady",
  334. this.onBridgeReady()
  335. );
  336. }
  337. } else {
  338. this.onBridgeReady();
  339. }
  340. }
  341. });
  342. },
  343. // 弹窗
  344. getOpen() {
  345. this.$refs.popup.open();
  346. },
  347. // 关闭
  348. getClose() {
  349. this.$refs.popup.close();
  350. },
  351. // 调起支付
  352. onBridgeReady() {
  353. WeixinJSBridge.invoke("getBrandWCPayRequest", this.form, function (res) {
  354. if (res.err_msg == "get_brand_wcpay_request:ok") {
  355. // 支付成功刷新页面
  356. location.reload();
  357. }
  358. });
  359. },
  360. // 开通记录
  361. getRouter() {
  362. uni.navigateTo({
  363. url: `/pages/pay/detail?state=${this.state}`,
  364. });
  365. },
  366. },
  367. };
  368. </script>
  369. <style lang="scss" scoped>
  370. .app-container {
  371. padding: 0;
  372. }
  373. .header {
  374. width: 100%;
  375. height: 368rpx;
  376. background: url("../../static/pay/bg.png") no-repeat 100% / 100%;
  377. .info {
  378. margin-bottom: 38rpx;
  379. .dev-img {
  380. background: rgba(0, 0, 0, 0.12);
  381. width: 120rpx;
  382. height: 120rpx;
  383. border-radius: 50%;
  384. margin: 64rpx 0 0 64rpx;
  385. img {
  386. width: 96rpx;
  387. height: 96rpx;
  388. }
  389. }
  390. .dev {
  391. width: calc(590rpx - 130rpx);
  392. margin-top: 88rpx;
  393. margin-left: 24rpx;
  394. .dev-name {
  395. font-size: 32rpx;
  396. margin-bottom: 8rpx;
  397. }
  398. .dev-history {
  399. color: #9fa5ad;
  400. font-size: 22rpx;
  401. }
  402. }
  403. }
  404. .progress {
  405. width: 100%;
  406. margin-bottom: 16rpx;
  407. ::v-deep uni-progress,
  408. .progress-info {
  409. width: 590rpx;
  410. .uni-progress-bar,
  411. .uni-progress-inner-bar {
  412. border-radius: 18rpx;
  413. }
  414. }
  415. .progress-info {
  416. font-size: 20rpx;
  417. color: #9fa5ad;
  418. margin-top: 8rpx;
  419. }
  420. }
  421. }
  422. .header-bg {
  423. height: 510rpx;
  424. background: url("../../static/pay/bigbg.png") no-repeat 100% / 100%;
  425. }
  426. .main {
  427. flex: 1;
  428. padding: 0 32rpx;
  429. margin-bottom: 320rpx;
  430. .title {
  431. align-items: center;
  432. }
  433. .active {
  434. background-color: rgba(199, 170, 134, 0.12);
  435. }
  436. .list {
  437. width: calc(100% / 3 - 10px);
  438. height: 268rpx;
  439. border: 1px solid #c7aa86;
  440. border-radius: 16rpx;
  441. padding: 48rpx 10px;
  442. color: #ffd5a0;
  443. position: relative;
  444. margin: 24rpx 5px 0;
  445. .flow {
  446. width: 100%;
  447. font-size: 28rpx;
  448. text-align: center;
  449. }
  450. .discount {
  451. font-size: 48rpx;
  452. }
  453. .price {
  454. font-size: 24rpx;
  455. text-decoration: line-through;
  456. opacity: 0.5;
  457. }
  458. .icon::before {
  459. content: "¥";
  460. font-size: 24rpx;
  461. }
  462. }
  463. .list::before {
  464. content: attr(data-content-before);
  465. position: absolute;
  466. left: -1px;
  467. top: -1px;
  468. background-color: #ffd5a0;
  469. color: #765626;
  470. font-size: 22rpx;
  471. border-radius: 16rpx 0 16rpx 0;
  472. padding: 0 16rpx;
  473. }
  474. .tag-name {
  475. position: absolute;
  476. left: 0px;
  477. bottom: -1px;
  478. background-color: #ffd5a0;
  479. color: #765626;
  480. font-size: 22rpx;
  481. width: 100%;
  482. text-align: center;
  483. border-radius: 0 0 16rpx 16rpx;
  484. }
  485. .explain {
  486. font-size: 24rpx;
  487. opacity: 0.5;
  488. margin-top: 24rpx;
  489. }
  490. }
  491. .footer {
  492. position: fixed;
  493. bottom: 0;
  494. left: 0;
  495. background: #181818;
  496. .warning {
  497. font-size: 22rpx;
  498. background-color: #2a2a2a;
  499. padding: 16rpx 32rpx;
  500. }
  501. }
  502. .popup {
  503. padding: 20px 24px 0;
  504. .title {
  505. text-align: center;
  506. font-size: 18px;
  507. }
  508. .content {
  509. padding: 16px 0 0 0;
  510. font-size: 14px;
  511. margin-bottom: 64rpx;
  512. h4 {
  513. font-weight: 100;
  514. line-height: 20px;
  515. margin-bottom: 10px;
  516. }
  517. }
  518. }
  519. button {
  520. width: calc(100% - 64rpx);
  521. height: 92rpx;
  522. display: flex;
  523. justify-content: center;
  524. align-items: center;
  525. background: linear-gradient(90deg, #f3cf97 0%, #f6e5c4 100%);
  526. border-radius: 23px;
  527. color: #7c541a;
  528. font-size: 32rpx;
  529. font-weight: bold;
  530. margin: 32rpx auto;
  531. }
  532. </style>