123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- 'use strict';
- // loading组件
- var LoadingWrap = {
- name: 'Loading',
- render: function render(h) {
- return h('div', { class: ['loading-wrap'] }, [h('img', { attrs: { src: '/img/alliance-page/loading.gif', alt: 'loading' } })]);
- }
- };
- function remove(el) {
- el.removeChild(el.instance.$el);
- }
- function append(el) {
- el.appendChild(el.instance.$el);
- }
- // 定义 loading 指令
- var loadingDirective = {
- inserted: function inserted(el, binding) {
- // 创建 loading 组件构造函数
- var LoadingCtor = Vue.extend(LoadingWrap);
- // new 一个 loading组件实例
- var loadingInstance = new LoadingCtor();
- // 组件挂载
- el.instance = loadingInstance.$mount();
- // 传入值为 true 时才展示
- if (binding.value) {
- // 将组件挂载到绑定指令的元素上
- append(el);
- }
- },
- update: function update(el, binding) {
- // 值更新时进行操作
- if (binding.value !== binding.oldValue) {
- binding.value ? append(el) : remove(el);
- }
- }
- };
- // vue实例
- var zplm = new Vue({
- el: '#zplm',
- directives: {
- loading: loadingDirective
- },
- data: {
- isPc: $(window).width() > 768,
- authCardVisible: false,
- statementVisible: false,
- showStatementContent: false,
- wechatVisible: true,
- showMask: false,
- isRequest: true,
- // 产品id
- productId: '',
- //产品参数对象
- productAuthInfo: {},
- //错误信息
- errorMessage: '',
- // 定时器
- timer: null
- },
- computed: {
- // 封面图 主图
- coverImage: function coverImage() {
- return this.isPc ? this.productAuthInfo.pcImage : this.productAuthInfo.appletsImage;
- },
- // 授权机构
- authOrigin: function authOrigin() {
- return this.productAuthInfo.agentFlag !== 0 ? this.productAuthInfo.shopName : this.productAuthInfo.brandName;
- },
- // 不换行
- noWarp: function noWarp() {
- if (this.isPc && this.productAuthInfo.paramList.length > 1) return { 'white-space': 'nowrap' };
- return '';
- }
- },
- created: function created() {
- this.getProductId();
- this.fetchProductAuthInfo();
- },
- filters: {
- // 处理sn码
- snCode: function snCode(code) {
- if (!code) return '';
- return code.replace(/^(\w{2})\w+(\w{4})$/, "$1******$2");
- }
- },
- methods: {
- // 获取商品id
- getProductId: function getProductId() {
- var productId = window.location.pathname.split('-')[1].split('.')[0];
- this.productId = parseInt(productId);
- },
- // 获取授权信息
- fetchProductAuthInfo: function fetchProductAuthInfo() {
- var that = this;
- var data = {productId:that.productId}
- $.ajax({
- url: 'https://zplma.caimei365.com/wx/auth/product/details',
- data: data,
- xhrFields: {//此处为跨域后台保持session一致,切勿删除!!!
- withCredentials: true
- },
- type: 'GET',
- dataType: "json",
- async: false,
- // contentType: contentType,
- contentType: 'application/json;charset=UTF-8',
- }).then(res => {
- // 获取授权信息失败
- if (res.code) {
- that.isRequest = false;
- return that.errorMessage = res.msg;
- }
- // 获取授权信息成功
- that.productAuthInfo = res.data;
- that.isRequest = false;
- })
- setTimeout(function(){
- if(that.isRequest){
- that.isRequest = false;
- location.href = '/404.html'
- }
- }, 10000)
- },
- // 显示授权牌
- handleShowAuthCard: function handleShowAuthCard() {
- this.authCardVisible = !this.authCardVisible;
- this.showMask = !this.showMask;
- },
- // 显示声明弹窗
- handleShowStatement: function handleShowStatement() {
- var that = this;
- this.statementVisible = !this.statementVisible;
- this.showMask = !this.showMask;
- this.timer = setTimeout(function () {
- that.showStatementContent = !that.showStatementContent;
- }, 800);
- },
- // 显示微信二维码
- handleShowWechat: function handleShowWechat() {
- this.wechatVisible = !this.wechatVisible;
- }
- }
- });
|