single_text_detail.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. .try-btn {
  15. position: fixed;
  16. bottom: 0;
  17. left: 0;
  18. z-index: 10;
  19. width: 100%;
  20. padding: .2rem .3rem;
  21. }
  22. .try-btn a {
  23. display: block;
  24. width: 100%;
  25. height: .88rem;
  26. border-radius: .44rem;
  27. background-color: #191C6E;
  28. font-size: .28rem;
  29. line-height: .88rem;
  30. text-align: center;
  31. color: #FFFFFF;
  32. }
  33. </style>
  34. {/block}
  35. {block name="content"}
  36. <div v-cloak id="app">
  37. <div class="single-text-detail">
  38. <div ref="header" class="header">
  39. <i class="iconfont iconxiangyou" @click="goBack"></i>
  40. <div>{{ title }}</div>
  41. </div>
  42. <div class="main" v-html="content.isPay ? content.content : profile.try_content"></div>
  43. <div v-if="!content.isPay" style="height: 1.28rem;"></div>
  44. <div v-if="!content.isPay" class="try-btn">
  45. <a href="javascript:" @click="handlePay">已试看,立即购买</a>
  46. </div>
  47. </div>
  48. <pay-dialog :open.sync="payDialogOpen" :money="content.money" :now_money="now_money" :special_id="id" :pay_type_num="2" :is-wechat="isWechat" :is-alipay="is_alipay"
  49. :is-balance="is_yue" :template-id="templateIds" :wxpay-h5="wxpayH5" :is-member="content.is_member" :member-money="content.member_money" :member-link="memberLink"
  50. @change="changeVal"></pay-dialog>
  51. </div>
  52. {/block}
  53. {block name="foot"}
  54. <script>
  55. require(['vue', 'helper', 'store', 'components/pay-dialog/index'], function (Vue, $h, $http, PayDialog) {
  56. var isWechat = {$isWechat? 'true': 'false'};
  57. var now_money = {$now_money};
  58. var is_alipay = {$is_alipay? 'true': 'false'};
  59. var is_yue = {$is_yue? 'true': 'false'};
  60. var wxpayH5 = {$is_h5_wechat_payment_switch? 'true': 'false'};
  61. var memberLink = "{:url('special/member_recharge')}";
  62. var id = {$id};
  63. var vm = new Vue({
  64. el: '#app',
  65. components: {
  66. 'pay-dialog': PayDialog
  67. },
  68. data: {
  69. title: '',
  70. profile: {},
  71. content: {
  72. isPay: true
  73. },
  74. id: id,
  75. isTry: '',
  76. payDialogOpen: false,
  77. now_money: now_money,
  78. isWechat: isWechat,
  79. is_alipay: is_alipay,
  80. is_yue: is_yue,
  81. templateIds: '',
  82. wxpayH5: wxpayH5,
  83. memberLink: memberLink,
  84. },
  85. created: function () {
  86. this.getDetail();
  87. },
  88. mounted: function () {
  89. this.$nextTick(function () {
  90. document.body.style.paddingTop = this.$refs.header.clientHeight + 'px';
  91. });
  92. },
  93. methods: {
  94. getDetail: function () {
  95. $h.loadFFF();
  96. $http.baseGet($h.U({
  97. c: 'special',
  98. a: 'single_img_content',
  99. q: {
  100. id: this.id
  101. }
  102. }), function (res) {
  103. var data = res.data.data;
  104. $h.loadClear();
  105. vm.title = data.title;
  106. vm.profile = data.profile;
  107. vm.content = data;
  108. if (isWechat) {
  109. mapleWx($jssdk(), function () {
  110. this.onMenuShareAll({
  111. title: vm.title,
  112. desc: vm.title,
  113. imgUrl: vm.image,
  114. link: data.link_url
  115. });
  116. });
  117. }
  118. }, function () {
  119. $h.loadClear();
  120. });
  121. },
  122. goBack: function () {
  123. window.location.href = "{:url('special/single_details')}?id=" + this.id;
  124. },
  125. handlePay: function () {
  126. this.payDialogOpen = true;
  127. },
  128. changeVal: function (opt) {
  129. if (typeof opt !== 'object') {
  130. opt = {};
  131. }
  132. var action = opt.action || '';
  133. var value = opt.value || '';
  134. this[action] && this[action](value);
  135. },
  136. // 支付方式回调
  137. pay_order: function (data) {
  138. this.orderId = data.data.result.orderId || '';
  139. switch (data.data.status) {
  140. case "PAY_ERROR":
  141. case 'ORDER_EXIST':
  142. case 'ORDER_ERROR':
  143. this.extendOrder(data.msg);
  144. break;
  145. case 'WECHAT_PAY':
  146. this.wechatPay(data.data.result.jsConfig);
  147. break;
  148. case 'WECHAT_H5_PAY':
  149. this.payDialogOpen = false;
  150. var callbackUrl = callback_url + '?type=7&id=' + this.special.id;
  151. var mwebUrl = data.data.result.jsConfig.mweb_url + '&redirect_url=' + encodeURIComponent(callbackUrl);
  152. window.location.assign(mwebUrl);
  153. break;
  154. case 'SUCCESS':
  155. this.successOrder(data.msg);
  156. break;
  157. case 'ZHIFUBAO_PAY':
  158. window.location.assign($h.U({
  159. c: 'alipay',
  160. a: 'index',
  161. q: {
  162. info: data.data.result,
  163. params: 'special'
  164. }
  165. }));
  166. break;
  167. }
  168. },
  169. // 微信支付
  170. wechatPay: function (config) {
  171. var vm = this;
  172. mapleWx($jssdk(), function () {
  173. this.chooseWXPay(config, function () {
  174. vm.successOrder();
  175. }, {
  176. fail: vm.extendOrder,
  177. cancel: vm.extendOrder
  178. });
  179. });
  180. },
  181. // 支付成功
  182. successOrder: function (msg) {
  183. var that = this;
  184. $h.showMsg({
  185. title: msg || '支付成功',
  186. icon: 'success',
  187. success: function () {
  188. that.payDialogOpen = false;
  189. that.$nextTick(function () {
  190. this.getDetail();
  191. });
  192. }
  193. });
  194. },
  195. // 支付未完成
  196. extendOrder: function (msg) {
  197. var that = this;
  198. if (typeof msg === 'object') {
  199. if (msg.errMsg === 'chooseWXPay:cancel') {
  200. msg = '微信支付取消';
  201. } else {
  202. msg = '支付失败';
  203. }
  204. } else {
  205. msg = '支付失败';
  206. }
  207. $h.pushMsg(msg, function () {
  208. that.payDialogOpen = false;
  209. if (that.orderId) {
  210. store.baseGet($h.U({
  211. c: 'special',
  212. a: 'del_order',
  213. q: {
  214. orderId: that.orderId
  215. }
  216. }));
  217. }
  218. });
  219. },
  220. }
  221. });
  222. });
  223. </script>
  224. {/block}