index.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. <!-- +---------------------------------------------------------------------- -->
  2. <!-- | CRMEB [ CRMEB赋能开发者,助力企业发展 ] -->
  3. <!-- +---------------------------------------------------------------------- -->
  4. <!-- | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved. -->
  5. <!-- +---------------------------------------------------------------------- -->
  6. <!-- | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权 -->
  7. <!-- +---------------------------------------------------------------------- -->
  8. <!-- | Author: CRMEB Team <admin@crmeb.com> -->
  9. <!-- +---------------------------------------------------------------------- -->
  10. {extend name="public/container"}
  11. {block name="title"}学习计划{/block}
  12. {block name="head"}
  13. <style>
  14. body {
  15. background: #F5F5F5;
  16. }
  17. .price-wrap {
  18. display: flex;
  19. align-items: center;
  20. font-size: .24rem;
  21. line-height: .33rem;
  22. color: #DC9845;
  23. }
  24. .price-wrap .price {
  25. flex: 1;
  26. font-weight: bold;
  27. font-size: .24rem;
  28. line-height: .45rem;
  29. color: #DC9845;
  30. }
  31. .price-wrap .price span {
  32. font-size: .32rem;
  33. }
  34. .activity-list li > div > div > div:last-child {
  35. font-weight: normal;
  36. }
  37. .activity-list .tab div{text-align: left; padding-left: 10px;}
  38. </style>
  39. {/block}
  40. {block name="content"}
  41. <div class="activity-list" v-cloak id="app">
  42. <div class="content">
  43. <ul v-if="activityList.length">
  44. <li v-for="(item, index) in activityList" :key="index">
  45. <div>
  46. <div>
  47. <img :src="item.plan_head" alt="" @click="planDetails(item.id)">
  48. </div>
  49. <div>
  50. <div @click="planDetails(item.id)">{{ item.plan_name }}</div>
  51. <div class="price-wrap">
  52. <div class="price" @click="planDetails(item.id)">¥<span>{{ item.sales }}</span></div>
  53. <div>
  54. <input class="zybt" @click="planDetails(item.id)" v-if="item.isbuy" value="开始学习" type="button"/>
  55. <input class="zybt" @click="OpenPay(item)" v-if="!item.isbuy" value="购买学习" type="button"/>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </li>
  61. </ul>
  62. <div v-if="!activityList.length && loadend" class="empty">
  63. <img src="{__WAP_PATH}zsff/images/empty.png" alt="暂无数据">
  64. <div>暂无数据</div>
  65. </div>
  66. </div>
  67. <quick-menu></quick-menu>
  68. <!-- 支付弹窗 -->
  69. <pay-dialog :open.sync="payDialogOpen" :money="money" :now_money="now_money" :special_id="planinfo.id" :link_pay_uid="link_pay_uid"
  70. :pay_type_num="pay_type_num" :pink-id="pinkId" :is-wechat="isWechat" :is-alipay="is_alipay" :is-balance="is_yue"
  71. :template-id="templateId" :wxpay-h5="wxpayH5" :is-member="isMember" @change="changeVal">
  72. </pay-dialog>
  73. <!-- 登录弹窗 -->
  74. <base-login :login-show="loginShow" :site-name="site_name" @login-close="loginClose"></base-login>
  75. </div>
  76. {/block}
  77. {block name="foot"}
  78. <script>
  79. require(['vue', 'store', 'helper', '{__WAP_PATH}zsff/js/quick.js',
  80. 'components/pay-dialog/index', 'components/base-login/index'
  81. ], function (Vue, store, $h, quick, PayDialog, BaseLogin) {
  82. var isPay = 0;
  83. var link_pay_uid = 0;
  84. var is_yue = {$is_yue? 'true': 'false'};
  85. var is_alipay = {$is_alipay? 'true': 'false'};
  86. var isWechat = {$isWechat? 'true': 'false'};
  87. var isPay = {$isPay? 'true': 'false'};
  88. var wxpayH5 = {$is_h5_wechat_payment_switch? 'true': 'false'};
  89. var now_money = {$now_money};
  90. var isMember = {$is_member};
  91. var site_name = '{$Auth_site_name}';
  92. var app = new Vue({
  93. el: '#app',
  94. components: {
  95. 'base-login': BaseLogin,
  96. 'pay-dialog': PayDialog,
  97. },
  98. data: {
  99. navs: ['全部', '待核销', '已核销'],
  100. navActive: 0,
  101. activityList: [],
  102. loading: false,
  103. loadend: false,
  104. page: 1,
  105. limit: 20,
  106. loadTitle:'',
  107. planinfo:{},
  108. //支付登录相关
  109. payDialogOpen: false,
  110. loginShow: false,
  111. is_pay: isPay,
  112. money:0,
  113. link_pay_uid:link_pay_uid,
  114. pay_type_num: 7, //新增的 学习计划支付类型
  115. pinkId: 0,
  116. isWechat: isWechat,
  117. is_pay: isPay,
  118. is_alipay: is_alipay, //支付宝是否开启
  119. is_yue: is_yue, //余额是否开启
  120. now_money: now_money, //余额
  121. templateId: '',
  122. wxpayH5:wxpayH5,
  123. isMember:isMember,
  124. site_name:site_name,
  125. },
  126. mounted: function () {
  127. this.geLogList();
  128. this.$nextTick(function () {
  129. this.init();
  130. });
  131. },
  132. methods: {
  133. init: function () {
  134. var that = this;
  135. window.addEventListener('scroll', function () {
  136. var clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
  137. scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight,
  138. scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
  139. if (clientHeight + scrollTop >= scrollHeight) {
  140. that.geLogList();
  141. }
  142. });
  143. },
  144. planDetails: function (order_id) {
  145. return window.location.href=$h.U({ c: 'studyplan', a: 'details', q: {id: order_id } });
  146. },
  147. study: function (id){
  148. return window.location.href=$h.U({ c: 'studyplan', a: 'gotoStudy', q: {id: id } });
  149. },
  150. // 获取学习记录
  151. geLogList: function () {
  152. var that = this;
  153. if (that.loading) return;
  154. if (that.loadend) return;
  155. that.loading = true;
  156. store.baseGet($h.U({ c: 'studyplan', a: 'index', p: { page: that.page, limit: that.limit, op:'list' } }), function (res) {
  157. var list = res.data.data;
  158. that.activityList.push.apply(that.activityList, list);
  159. that.loadend = list.length < that.limit;
  160. that.loadTitle = that.loadend ? '已全部加载完' : '上拉加载更多';
  161. that.page = that.page + 1;
  162. that.loading = false;
  163. that.$set(this, 'activityList', that.activityList);
  164. }, function (res) {
  165. that.loadTitle = '上拉加载更多';
  166. that.loading = false;
  167. });
  168. },
  169. //所有插件回调处理事件
  170. changeVal: function (opt) {
  171. if (typeof opt != 'object') opt = {};
  172. var action = opt.action || '';
  173. var value = opt.value || '';
  174. this[action] && this[action](value);
  175. },
  176. pay_order: function (data) {
  177. this.orderId = data.data.result.orderId || '';
  178. switch (data.data.status) {
  179. case "PAY_ERROR":
  180. case 'ORDER_EXIST':
  181. case 'ORDER_ERROR':
  182. this.extendOrder(data.msg);
  183. break;
  184. case 'WECHAT_PAY':
  185. this.wechatPay(data.data.result.jsConfig);
  186. break;
  187. case 'WECHAT_H5_PAY':
  188. this.payDialogOpen = false;
  189. var callbackUrl = callback_url + '?type=9&id=' + this.planinfo.id;
  190. var mwebUrl = data.data.result.jsConfig.mweb_url + '&redirect_url=' + encodeURIComponent(callbackUrl);
  191. window.location.href = mwebUrl;
  192. break;
  193. case 'SUCCESS':
  194. this.successOrder(data.msg);
  195. break;
  196. case 'ZHIFUBAO_PAY':
  197. window.location.href = $h.U({
  198. m: 'wap',
  199. c: 'alipay',
  200. a: 'index',
  201. q: {info: data.data.result, params: 'plan'}
  202. });
  203. break;
  204. }
  205. },
  206. wechatPay: function (config) {
  207. var that = this;
  208. mapleWx($jssdk(), function () {
  209. this.chooseWXPay(config, function () {
  210. that.successOrder();
  211. }, {
  212. fail: that.extendOrder,
  213. cancel: that.extendOrder
  214. });
  215. });
  216. },
  217. successOrder: function (msg) {
  218. var that = this;
  219. $h.showMsg({
  220. title: msg ? msg : '支付成功',
  221. icon: 'success',
  222. success: function () {
  223. that.paid = true;
  224. that.is_pay = true;
  225. that.payDialogOpen = false;
  226. var opt = {
  227. c: 'studyplan',
  228. a: 'details',
  229. q: {
  230. id: that.planinfo.id
  231. }
  232. };
  233. window.location.assign($h.U(opt));
  234. }
  235. });
  236. },
  237. extendOrder: function (msg) {
  238. var that = this;
  239. if (typeof msg === 'object') {
  240. if (msg.errMsg === 'chooseWXPay:cancel') {
  241. msg = '微信支付取消';
  242. } else {
  243. msg = '支付失败';
  244. }
  245. } else {
  246. msg = '支付失败';
  247. }
  248. $h.pushMsg(msg, function () {
  249. that.payDialogOpen = false;
  250. if (that.orderId) {
  251. store.baseGet($h.U({c: 'studyplan', a: 'del_order', q: {orderId: that.orderId}}));
  252. }
  253. });
  254. },
  255. //打开支付插件,并检测登录状态,没有登录,打开登录插件
  256. OpenPay: function (plan) {
  257. this.planinfo = plan;
  258. this.money = plan.sales;
  259. var vm = this;
  260. store.baseGet($h.U({c: 'index', a: 'user_login'}), function (res) {
  261. this.payDialogOpen = true;
  262. // var opt = {
  263. // c: 'studyplan',
  264. // a: 'details',
  265. // q: {
  266. // id: this.planinfo.id
  267. // }
  268. // };
  269. // window.location.assign($h.U(opt));
  270. }.bind(this), function () {
  271. vm.loginShow = true;
  272. });
  273. },
  274. //关闭登录
  275. loginClose: function (val) {
  276. this.loginShow = false;
  277. val && this.logComplete();
  278. },
  279. }
  280. });
  281. });
  282. </script>
  283. {/block}