PeriodExchange.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="periodExchange">
  3. <m-header v-if="headerStatus" />
  4. <van-cell-group>
  5. <van-cell :center="true">
  6. <template slot="icon">
  7. <img class="logo" v-if="userInfo.avatar" :src="userInfo.avatar" alt="" />
  8. <img class="logo" v-else src="@/assets/images/icon_student.png" alt="" />
  9. </template>
  10. <template slot="title">
  11. <p class="exchangeText">{{ userInfo.realName }}</p>
  12. </template>
  13. <template slot="label">
  14. <p class="info">剩余时长:{{ availableMinutes }}</p>
  15. </template>
  16. </van-cell>
  17. </van-cell-group>
  18. <div class="activeList" v-if="dataShow">
  19. <h2>优惠活动:</h2>
  20. <div class="active" @click="onPayOrder(item)" v-for="(item, index) in dataList" :key="index">
  21. <van-icon name="question-o" v-if="imageStatus" @click.stop="onMore(item)" class="icon_question" />
  22. <!-- <img :src="item.coverImg" alt=""> -->
  23. <van-image :src="item.coverImg" @load="onImageLoad">
  24. <template v-slot:loading>
  25. <van-loading type="spinner" size="20" />
  26. </template>
  27. </van-image>
  28. </div>
  29. </div>
  30. <div class="activeList" v-else>
  31. <h2>优惠活动:</h2>
  32. <m-empty class="empty" msg="暂无优惠活动" key="data" />
  33. </div>
  34. <!-- <div class="pay_btn" >确认兑换</div> -->
  35. <van-popup v-model="popupShow" closeable position="bottom" :style="{ minHeight: '30%', maxHeight: '60%' }">
  36. <div class="popupContent" v-html="popupContent"></div>
  37. </van-popup>
  38. <m-payment :closeStatus="isStatus" :amount="payMoney" :payment="payment" @onChangeStatus="onChangeStatus" />
  39. </div>
  40. </template>
  41. <script>
  42. /* eslint-disable */
  43. import MHeader from "@/components/MHeader";
  44. import MEmpty from "@/components/MEmpty";
  45. import MPayment from "@/components/MPayment";
  46. import { browser, calcMinute } from "@/common/common";
  47. import { tenantEntryActivitesList, queryUserInfo, sysTenantAccountGet, createOrder } from "@/api/app";
  48. export default {
  49. name: "courseApply",
  50. components: { MHeader, MEmpty, MPayment },
  51. data() {
  52. return {
  53. userInfo: {},
  54. availableMinutes: 0,
  55. headerStatus: true,
  56. result: {}, // 生成订单的数据
  57. dataList: [],
  58. isClick: false,
  59. popupShow: false,
  60. popupContent: null,
  61. dataShow: true, // 是否有数据
  62. imageStatus: false,
  63. isStatus: false,
  64. payment: {}, // 支付对象
  65. payMoney: 0,
  66. };
  67. },
  68. mounted() {
  69. let params = this.$route.query;
  70. if (params.Authorization) {
  71. localStorage.setItem("Authorization", decodeURI(params.Authorization));
  72. localStorage.setItem("userInfo", decodeURI(params.Authorization));
  73. }
  74. document.title = "课时兑换";
  75. if (browser().android || browser().iPhone) {
  76. this.headerStatus = false;
  77. }
  78. this.__init();
  79. },
  80. methods: {
  81. async __init() {
  82. let loadingStatus = true;
  83. this.$toast.loading({
  84. duration: 0,
  85. message: "加载中...",
  86. forbidClick: true,
  87. loadingType: "spinner",
  88. });
  89. await queryUserInfo().then((res) => {
  90. let result = res.data;
  91. if (result) {
  92. this.userInfo = result;
  93. }
  94. });
  95. await sysTenantAccountGet().then((res) => {
  96. let result = res.data;
  97. if (result.code == 200) {
  98. let tempResult = result.data;
  99. if (tempResult) {
  100. this.availableMinutes = calcMinute(tempResult.availableMinutes ? tempResult.availableMinutes : 0);
  101. }
  102. } else {
  103. loadingStatus = false;
  104. this.$toast(result.msg);
  105. }
  106. });
  107. await tenantEntryActivitesList().then((res) => {
  108. let result = res.data;
  109. if (result.code == 200) {
  110. this.dataList = result.data.rows ? result.data.rows : [];
  111. } else {
  112. loadingStatus = false;
  113. this.$toast(result.msg);
  114. }
  115. if (this.dataList.length <= 0) {
  116. this.dataShow = false;
  117. }
  118. });
  119. if (loadingStatus) {
  120. this.$toast.clear();
  121. }
  122. },
  123. onImageLoad() {
  124. this.imageStatus = true;
  125. },
  126. onPayOrder(item) {
  127. // activitiesId
  128. if (this.isClick) {
  129. return;
  130. }
  131. this.$toast.loading({
  132. duration: 0,
  133. message: "加载中...",
  134. forbidClick: true,
  135. loadingType: "spinner",
  136. });
  137. this.isClick = true;
  138. createOrder({ activitiesId: item.id }).then((res) => {
  139. let result = res.data;
  140. this.$toast.clear();
  141. this.isClick = false;
  142. if (result.code == 200) {
  143. this.result = result.data;
  144. this.onSubmit();
  145. } else if (result.code == 100) {
  146. this.$dialog
  147. .confirm({
  148. // title: '提示',
  149. message: result.data,
  150. confirmButtonColor: "#269a93",
  151. cancelButtonText: "取消",
  152. confirmButtonText: "继续付款",
  153. })
  154. .then(() => {
  155. this.$toast.loading({
  156. duration: 0,
  157. message: "加载中...",
  158. forbidClick: true,
  159. loadingType: "spinner",
  160. });
  161. // 继续支付
  162. createOrder({ activitiesId: item.id, isContinuePay: true }).then((res) => {
  163. let result = res.data;
  164. this.$toast.clear();
  165. if (result.code == 200) {
  166. this.result = result.data;
  167. this.onSubmit();
  168. } else {
  169. this.$toast(result.msg);
  170. }
  171. });
  172. });
  173. } else {
  174. this.$toast(result.msg);
  175. }
  176. });
  177. },
  178. onChangeStatus(val) {
  179. this.isStatus = val;
  180. },
  181. onSubmit() {
  182. // submit 提交
  183. let result = this.result;
  184. let f = result.payMap;
  185. this.payMoney = Number(f.amount);
  186. if (result.type == "YQPAY") {
  187. document.querySelector("#onSubmit").action = f.host;
  188. document.querySelector("#apiContent").value = f.apiContent;
  189. document.querySelector("#merNo").value = f.merNo;
  190. document.querySelector("#notifyUrl").value = f.notifyUrl;
  191. document.querySelector("#sign").value = f.sign;
  192. document.querySelector("#signType").value = f.signType;
  193. document.querySelector("#timestamp").value = f.timestamp;
  194. document.querySelector("#version").value = f.version;
  195. document.querySelector("#onSubmit").submit();
  196. } else if (result.type == "ADAPAY" || result.type == "YEEPAY") {
  197. // 汇付天下
  198. this.payment = result;
  199. // 开始支付窗口
  200. this.isStatus = true;
  201. }
  202. },
  203. onMore(item) {
  204. this.popupContent = item.detail;
  205. this.popupShow = true;
  206. },
  207. },
  208. };
  209. </script>
  210. <style lang="less" scoped>
  211. @import url("../../assets/commonLess/variable.less");
  212. .periodExchange {
  213. min-height: 100vh;
  214. position: relative;
  215. background: #fff;
  216. .logo {
  217. width: 0.5rem;
  218. height: 0.5rem;
  219. border-radius: 50%;
  220. overflow: hidden;
  221. margin-right: 0.13rem;
  222. }
  223. /deep/.van-cell {
  224. margin-top: -1px;
  225. padding: 0.26rem 0.16rem 0.15rem;
  226. // background: #14928A;
  227. line-height: 0.24rem;
  228. }
  229. .exchangeText {
  230. font-size: 0.21rem;
  231. color: #1a1a1a;
  232. font-weight: 500;
  233. }
  234. .info {
  235. font-size: 0.14rem;
  236. color: #808080;
  237. }
  238. [class*="van-hairline"] {
  239. &::after {
  240. border: 0 solid #fff;
  241. }
  242. }
  243. }
  244. .activeList {
  245. padding: 0.15rem 0.16rem 0;
  246. // margin-top: -.6rem;
  247. position: relative;
  248. z-index: 49;
  249. h2 {
  250. font-size: 0.16rem;
  251. color: #444;
  252. padding-left: 0.15rem;
  253. padding-bottom: 0.15rem;
  254. position: relative;
  255. &::before {
  256. content: " ";
  257. width: 0.04rem;
  258. height: 0.15rem;
  259. background: @mColor;
  260. border-radius: 0.02rem;
  261. position: absolute;
  262. left: 0.02rem;
  263. top: 0.04rem;
  264. }
  265. span {
  266. float: right;
  267. }
  268. }
  269. .active {
  270. position: relative;
  271. margin-bottom: 0.15rem;
  272. line-height: 0;
  273. // box-shadow:0px 0px 16px 0px rgba(155,145,41,0.19);
  274. }
  275. img {
  276. width: 100%;
  277. }
  278. .icon_question {
  279. position: absolute;
  280. z-index: 10;
  281. bottom: 0.06rem;
  282. right: 0.12rem;
  283. color: #e94a47;
  284. font-size: 0.18rem;
  285. }
  286. }
  287. .popupContent {
  288. padding: 0.4rem 0.16rem 0.1rem;
  289. }
  290. .van-image {
  291. display: block;
  292. width: 100%;
  293. min-width: 1rem;
  294. }
  295. .pay_btn {
  296. background: @mColor;
  297. line-height: 0.45rem;
  298. color: #fff;
  299. font-size: 0.18rem;
  300. border-radius: 0.5rem;
  301. text-align: center;
  302. position: absolute;
  303. width: 90%;
  304. margin-left: 5%;
  305. bottom: 0.2rem;
  306. }
  307. </style>