金诚优选前端代码
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.

299 lines
8.0 KiB

  1. <template>
  2. <view id="off-detail" v-if="init">
  3. <view class="coupon" @tap="changeShare">
  4. <view class="coupon-left" :class="is_coupon != 1 ? 'discount' : ''" :style="'background: ' + config.mainColor">
  5. <view class="text-wrap">
  6. <view class="text-box">
  7. <view class="text">
  8. <text class="money" v-if="detail.action_type.type == 'cash'"></text>
  9. <sapn>{{ detail.action_type.value }}</sapn>
  10. <text class="money" v-if="detail.action_type.type == 'discount'"></text>
  11. </view>
  12. <text class="label text">{{ detail.label }}</text>
  13. </view>
  14. </view>
  15. <view class="dot-wrap">
  16. <view class="dot-item">
  17. </view>
  18. <view class="dot-item">
  19. </view>
  20. <view class="dot-item">
  21. </view>
  22. <view class="dot-item">
  23. </view>
  24. <view class="dot-item">
  25. </view>
  26. <view class="dot-item">
  27. </view>
  28. <view class="dot-item">
  29. </view>
  30. <view class="dot-item">
  31. </view>
  32. </view>
  33. </view>
  34. <view class="coupon-right">
  35. <view class="top">
  36. <span class="type">
  37. <span v-if="detail.channel == 'ec'">商城</span>
  38. <span v-else>门店</span>
  39. </span>
  40. <text class="info">{{detail.title}}</text>
  41. </view>
  42. <view class="bottom">
  43. <view class="bottom-use">
  44. <view class="tiem-box">
  45. <text>{{detail.use_start_time}}{{detail.use_end_time}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="share mx-1px-top" v-if="detail.agent_code">
  50. <view class="text">
  51. <i class="iconfont icon-fenxianganniu"></i>
  52. <view>分享优惠券</view>
  53. </view>
  54. <view class="iconfont icon-jiantou">
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="detail-item user-info" v-if="detail.intro">
  60. <view class="title">
  61. 使用说明
  62. </view>
  63. <view class="info mx-1px-top">
  64. {{detail.intro}}
  65. </view>
  66. </view>
  67. <view class="qr_code" v-if="detail.qr_code_img">
  68. <image :src="detail.qr_code_img"></image>
  69. </view>
  70. <view class="button-box" v-if="is_coupon == 1 && detail.agent_code" :style="'background: ' + config.mainColor">
  71. <view class="btn" @tap="changeShare">
  72. 点击分享
  73. </view>
  74. </view>
  75. <!--弹出分享部分-->
  76. <view class="maks" :class="show_share ? 'cur' : ''" @tap="changeShare">
  77. </view>
  78. <view class="share-box" :class="show_share ? 'cur' : ''">
  79. <!-- #ifdef MP-WEIXIN -->
  80. <button class="shaer-item" open-type="share">
  81. 分享给好友
  82. </button>
  83. <!-- #endif -->
  84. <!-- #ifdef APP-PLUS -->
  85. <button class="shaer-item" @click="shareapp">
  86. 分享给好友
  87. </button>
  88. <!-- #endif -->
  89. <view class="shaer-item mx-1px-top" @tap="getShearImg">
  90. 生成海报
  91. </view>
  92. <view class="shaer-item clear" @tap="changeShare">
  93. 取消
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  100. export default {
  101. data() {
  102. return {
  103. detail: '',
  104. barcode: '',
  105. is_coupon: 1,
  106. // 用于判断是否为优惠券 1:优惠券 0:促销折扣
  107. init: false,
  108. show_share: false,
  109. config: ''
  110. };
  111. },
  112. onShareAppMessage() {
  113. this.setData({
  114. show_share: false
  115. });
  116. return {
  117. title: this.detail.title,
  118. path: '/pages/coupon/onDetail/onDetail?id=' + this.id + '&is_coupon=1&agent_code=' + this.detail.agent_code
  119. };
  120. },
  121. onLoad(e) {
  122. // 第三方平台配置颜色
  123. var gbConfig = this.$cookieStorage.get('globalConfig') || '';
  124. this.setData({
  125. config: gbConfig
  126. });
  127. var id = e.id;
  128. var coupon_id = e.coupon_id;
  129. this.setData({
  130. id: e.id
  131. });
  132. this.queryCouponDetail(id, coupon_id);
  133. },
  134. methods: {
  135. // 分享给app的好友
  136. shareapp(){
  137. this.setData({
  138. show_share: false
  139. });
  140. var title = this.detail.title;
  141. var id = this.id;
  142. var agent_code = this.detail.agent_code;
  143. uni.getProvider({
  144. service:'share',
  145. success:function(res){
  146. uni.share({
  147. provider: "weixin",
  148. scene: "WXSceneSession",
  149. type: 5,
  150. title:title,
  151. imageUrl:'https://cdn.guojiang.club/guojiang_logo.png',
  152. miniProgram:{
  153. id:'gh_72e65196278a',
  154. path:'pages/coupon/onDetail/onDetail?id=' + id + '&is_coupon=1&agent_code=' + agent_code,
  155. type:0,
  156. webUrl: 'https://guojiang.club'
  157. },
  158. success: function (res) {
  159. console.log("success:" + JSON.stringify(res));
  160. },
  161. fail: function (err) {
  162. console.log("fail:" + JSON.stringify(err));
  163. }
  164. });
  165. }
  166. })
  167. },
  168. changeShare() {
  169. this.setData({
  170. show_share: !this.show_share
  171. });
  172. },
  173. //生成海报
  174. getShearImg() {
  175. wx.navigateTo({
  176. url: '/pages/distribution/shareImg/shareImg?id=' + this.id + '&channel=' + this.detail.channel
  177. });
  178. this.changeShare();
  179. },
  180. // 查询优惠券详情
  181. queryCouponDetail(id, coupon_id) {
  182. wx.showLoading({
  183. title: "加载中",
  184. mask: true
  185. });
  186. var coupon_ids = coupon_id ? coupon_id : '';
  187. var token = this.$cookieStorage.get('user_token');
  188. this.$http.get({
  189. api: 'api/discount/' + id + '/detail',
  190. data: {
  191. is_agent: 1,
  192. coupon_id: coupon_ids
  193. },
  194. header: {
  195. Authorization: token
  196. }
  197. }).then(res => {
  198. if (res.statusCode == 200) {
  199. res = res.data;
  200. if (res.status) {
  201. this.setData({
  202. detail: res.data,
  203. init: true
  204. });
  205. if (!res.data.agent_code) {
  206. wx.showModal({
  207. content: '当前用户非分销员',
  208. showCancel: false,
  209. success: res => {
  210. if (res.confirm || !res.cancel && !res.confirm) {
  211. wx.navigateBack({
  212. delta: 1
  213. });
  214. }
  215. }
  216. });
  217. this.setData({
  218. init: false
  219. });
  220. wx.hideShareMenu();
  221. }
  222. } else {
  223. wx.hideShareMenu();
  224. wx.showModal({
  225. content: res.message || '请求失败',
  226. showCancel: false
  227. });
  228. }
  229. } else {
  230. wx.hideShareMenu();
  231. wx.showModal({
  232. content: "请求失败",
  233. showCancel: false
  234. });
  235. }
  236. wx.hideLoading();
  237. }).catch(rej => {
  238. wx.hideShareMenu();
  239. wx.hideLoading();
  240. wx.showModal({
  241. content: '请求失败',
  242. showCancel: false
  243. });
  244. });
  245. },
  246. setData: function (obj) {
  247. let that = this;
  248. let keys = [];
  249. let val, data;
  250. Object.keys(obj).forEach(function (key) {
  251. keys = key.split('.');
  252. val = obj[key];
  253. data = that.$data;
  254. keys.forEach(function (key2, index) {
  255. if (index + 1 == keys.length) {
  256. that.$set(data, key2, val);
  257. } else {
  258. if (!data[key2]) {
  259. that.$set(data, key2, {});
  260. }
  261. }
  262. data = data[key2];
  263. });
  264. });
  265. }
  266. },
  267. computed: {},
  268. watch: {}
  269. };
  270. </script>
  271. <style rel="stylesheet/less" lang="less">
  272. @import "offDetail";
  273. </style>