Commit 02dda58d by 张立顺

支付宝功能开发

1 parent dae1d7e2
Showing 70 changed files with 979 additions and 3137 deletions
...@@ -224,7 +224,8 @@ module.exports = { ...@@ -224,7 +224,8 @@ module.exports = {
} }
], ],
'space-before-blocks': [2, 'always'], 'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'], // 'space-before-function-paren': [2, 'never'],
'space-before-function-paren': ['error', 'never'],
'space-in-parens': [2, 'never'], 'space-in-parens': [2, 'never'],
'space-infix-ops': 2, 'space-infix-ops': 2,
'space-unary-ops': [ 'space-unary-ops': [
......
...@@ -5,19 +5,21 @@ ...@@ -5,19 +5,21 @@
"author": "limin <limin.mail@qq.com>", "author": "limin <limin.mail@qq.com>",
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve --open", "serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve ",
"build": "vue-cli-service build", "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build",
"stage": "vue-cli-service build --mode staging", "stage": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build --mode staging",
"lint": "vue-cli-service lint --fix", "lint": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service lint --fix",
"dev": "npm run serve" "dev": "set NODE_OPTIONS=--openssl-legacy-provider && npm run serve"
}, },
"dependencies": { "dependencies": {
"autoprefixer": "^8.0.0", "autoprefixer": "^8.0.0",
"axios": "^0.27.2",
"core-js": "^3.6.4", "core-js": "^3.6.4",
"dayjs": "^1.10.5", "dayjs": "^1.10.5",
"glsx-common": "^1.4.9",
"lib-flexible": "^0.3.2", "lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0", "postcss-loader": "^6.2.0",
"qs": "^6.11.0",
"sass": "^1.54.4",
"sha1": "^1.1.1", "sha1": "^1.1.1",
"storejs": "^1.1.0", "storejs": "^1.1.0",
"vant": "^2.12.21", "vant": "^2.12.21",
...@@ -38,7 +40,6 @@ ...@@ -38,7 +40,6 @@
"babel-plugin-transform-remove-console": "^6.9.4", "babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^6.7.2", "eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2", "eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.14.1",
"postcss-px-to-viewport": "^1.1.1", "postcss-px-to-viewport": "^1.1.1",
"postcss-pxtorem": "^5.1.1", "postcss-pxtorem": "^5.1.1",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
......
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no,viewport-fit=cover"> <meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no,viewport-fit=cover">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %> <% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" /> <link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
...@@ -18,8 +19,9 @@ ...@@ -18,8 +19,9 @@
to continue.</strong> to continue.</strong>
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> <script src="https://gw.alipayobjects.com/as/g/h5-lib/alipayjsapi/3.1.1/alipayjsapi.min.js"> </script>
<script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script> <!-- <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script> -->
<!-- <script src="https://open.work.weixin.qq.com/wwopen/js/jwxwork-1.0.0.js"></script> -->
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 --> <!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %> <% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script> <script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
......
<template> <template>
<div id="app"> <div id="app">
<template v-if="showWindow"> <!-- v-if="showWindow" -->
<template>
<transition name="fade"> <transition name="fade">
<keep-alive v-if="$route.meta.keepAlive"> <keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view> <router-view></router-view>
...@@ -9,9 +10,9 @@ ...@@ -9,9 +10,9 @@
<transition name="fade"> <transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view> <router-view v-if="!$route.meta.keepAlive"></router-view>
</transition> </transition>
<template v-if="$route.meta.isTab && entry != 'normal'"> <!-- <template v-if="$route.meta.isTab && entry != 'normal'">
<tab-bar :data="tabList"></tab-bar> <tab-bar :data="tabList"></tab-bar>
</template> </template> -->
</template> </template>
</div> </div>
</template> </template>
...@@ -21,36 +22,36 @@ export default { ...@@ -21,36 +22,36 @@ export default {
name: 'App', name: 'App',
data() { data() {
return { return {
entry: IS_PROD ? 'normal' :'chat_attachment', entry: IS_PROD ? 'normal' : 'chat_attachment'
tabList: [ // tabList: [
{ // {
title: '卡券', // title: '卡券',
name: 'coupon', // name: 'coupon',
active: require('@/assets/images/tabbar/coupon_active.png'), // active: require('@/assets/images/tabbar/coupon_active.png'),
inactive: require('@/assets/images/tabbar/coupon.png') // inactive: require('@/assets/images/tabbar/coupon.png')
}, // },
{ // {
title: '活动', // title: '活动',
name: 'activity', // name: 'activity',
active: require('@/assets/images/tabbar/activity_active.png'), // active: require('@/assets/images/tabbar/activity_active.png'),
inactive: require('@/assets/images/tabbar/activity.png') // inactive: require('@/assets/images/tabbar/activity.png')
} // }
] // ]
} }
}, },
watch: { watch: {
watchFlag: { // watchFlag: {
immediate: true, // immediate: true,
handler(newval) { // handler(newval) {
this.showWindow = newval // this.showWindow = newval
this.hideLoading() // this.hideLoading()
} // }
} // }
}, },
computed: { computed: {
watchFlag() { // watchFlag() {
return this.$store.state.app.showWindow // return this.$store.state.app.showWindow
} // }
}, },
mounted() { mounted() {
}, },
...@@ -59,8 +60,8 @@ export default { ...@@ -59,8 +60,8 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.isTab { // .isTab {
padding-bottom: 50px; // padding-bottom: 50px;
box-sizing: border-box; // box-sizing: border-box;
} // }
</style> </style>
const url = '/rop-scrm-shopmall/router'
export default {
/** 分页查询活动 */
getActivityList (currentPage) {
let data = {
method: 'scrm.api.shopmall.activity.page',
pageSize: 10,
currentPage
}
return window.$HTTP({
url,
data
})
},
/** 获取分享链接 */
getShared (data) {
data.method = 'scrm.api.shopmall.activity.get.shared'
return window.$HTTP({
url,
data
})
},
}
\ No newline at end of file \ No newline at end of file
import request from './request'
import RequestMethods from './request.methods'
const path = 'dj.api.'
export function getProductType(data) {
data.method = `${path}goods.type.list`
return request(data)
}
// 银行列表
export function getBankListApi(data) {
data.method = `${path}yseBankInfo.bankList`
console.log(data)
return request(data, RequestMethods.POST)
}
import store from '@/store'
import axios from 'axios'
// import { Message } from 'element-ui'
import { Notify } from 'vant'
import log from '@/utils/log'
// import router from '@/router'
import { baseConfig } from '@/main'
import Qs from 'qs'
axios.defaults.withCredentials = true
// const expiresMinute = 60 // 过期时间(分钟)
// 创建一个错误
export function errorCreate(msg) {
const error = new Error(msg)
errorLog(error)
throw error
}
// 记录和显示错误
function errorLog(error) {
// 添加到日志
// store.dispatch('d2admin/log/push', {
// message: '数据请求异常',
// type: 'danger',
// meta: {
// error
// }
// })
// 打印到控制台
if (process.env.NODE_ENV === 'development') {
log.danger('>>>>>> Error >>>>>>')
console.log(error)
}
// 显示提示
Notify({
message: error.message,
type: 'error',
duration: 5 * 1000
})
}
// 网络请求公用地址 http://192.168.3.171:7300/mock/5d638b3b6fbe9a0ac59d872e/tFIMS
// VUE_APP_API=http://192.168.3.191:8944/router
// 创建一个 axios 实例
const service = axios.create({
// baseURL: baseURL,
timeout: 100000, // 请求超时时间
transformRequest: [
function (data) {
return Qs.stringify(data)
}
]
})
// 请求拦截器
service.interceptors.request.use(
config => {
return new Promise(async resolve => {
// await store.commit('d2admin/loading/set', true)
// const uuid = util.cookies.get('uuid')
// 如果请求链接不在排除列表 (排除列表: 登录 基础数据) 并且cookie 过期(判断是否长时间未操作)
// if (!LogExternals.some(u => u === url || (params && u === params.method)) && !uuid) {
// await store.dispatch('d2admin/account/logout')
// router.replace('/login')
// }
// if (uuid) { // 判断 cookie 是否存在 存在则更新时间 避免登出时 记录空值
// const inExpiresMinutes = new Date(new Date().getTime() + expiresMinute * 60 * 1000)
// util.cookies.set('uuid', uuid, {
// expires: inExpiresMinutes
// })
// }
// config.url = baseConfig.axios.baseURL + config.url
// console.log(config.data.method.includes('dj.api.common.uploadImg'))
// console.log(config)
// console.log(Object.prototype.toString.call(config.data))
// console.log(config.data.method)
// if (process.env.NODE_ENV == 'development') {
// // 处理图片开发环境没用的问题
// const type = Object.prototype.toString.call(config.data)
// const methodList = ['dj.api.common.uploadImg', 'dj.api.common.ocr.recognition', 'dj.api.smartcarlife.sms.sendSmsCode']
// if (type == '[object Object]' && methodList.includes(config.data.method)) {
// config.url = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// } else {
// config.url = baseConfig.axios.baseURL
// }
// } else {
// }
// config.url = baseConfig.axios.baseURL
// if (config.params && config.params.method.includes('common.uploadImg')) {
// config.url = 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
// } else {
// config.url = baseConfig.axios.baseURL
// }
// config.url = baseConfig.axios.baseURL
// config.timeout = baseConfig.axios.timeout
resolve(config)
})
},
error => {
store.commit('d2admin/loading/set', false)
// 发送失败
console.log(error)
Promise.reject(error)
}
)
// 响应拦截器
service.interceptors.response.use(
response => {
// console.log(response)
// store.commit('d2admin/loading/set', false)
// dataAxios 是 axios 返回数据中的 data
// const dataAxios = {
// code: "20",
// message: "缺少sessionId参数",
// solution: "将添加会话ID请求参数",
// subErrors: null
// }
const dataAxios = response.data
const ruleResult = baseConfig.axios.result
// 这个状态码是和后端约定的
// 有 code 代表这是一个后端接口 可以进行进一步的判断
var goBackArr = ['20', '21']
// console.log(dataAxios[ruleResult.code_key])
// if (goBackArr.includes(dataAxios[ruleResult.code_key])) {
// // await store.dispatch('d2admin/account/logout')
// store.dispatch('d2admin/user/clear')
// util.cookies.remove('token')
// router.replace('/login')
// return Promise.reject(new Error('登录超时,请重新登录'))
// // return Promise.reject(new Error(response.message || 'Error'))
// }
switch (+dataAxios[ruleResult.code_key]) {
case ruleResult.code_success_value:
// [ 示例 ] code === 0 代表没有错误
return dataAxios[ruleResult.data_key]
default:
// 不是正确的 code
errorCreate(`${dataAxios[ruleResult.message_key]}`)
break
}
},
error => {
if (error && error.response) {
switch (error.response.status) {
case 400:
error.message = '请求错误'
break
case 401:
error.message = '未授权,请登录'
break
case 403:
error.message = '拒绝访问'
break
case 404:
error.message = `请求地址出错: ${error.response.config.url}`
break
case 408:
error.message = '请求超时'
break
case 500:
error.message = '服务器内部错误'
break
case 501:
error.message = '服务未实现'
break
case 502:
error.message = '网关错误'
break
case 503:
error.message = '服务不可用'
break
case 504:
error.message = '网关超时'
break
case 505:
error.message = 'HTTP版本不受支持'
break
default:
break
}
}
if (error && error.stack.indexOf('timeout') > -1) {
if (error.stack.indexOf('5000ms')) {
error.message = '查询超时,请刷新页面重试!'
}
// console.log('超时')
// console.log(error)
}
// store.commit("d2admin/loading/set", false)
errorLog(error)
return Promise.reject(error)
}
)
export default service
const url = '/rop-scrm-boutiquecoupon/router'
export default {
/**精品礼券分页查询 */
getBoutiqueCouponList(data) {
data.method = 'scrm.api.boutiquecoupon.wework.coupon.page'
data.pageSize = 10
return window.$HTTP({
// url: 'http://192.168.3.222:8489/rop-scrm-boutiquecoupon/router',
url,
data
})
},
/**精品礼券领取链接 */
getBoutiqueCoupon(data) {
data.method = 'scrm.api.boutiquecoupon.wework.coupon.receiveUrl'
return window.$HTTP({
// url: 'http://192.168.3.222:8489/rop-scrm-boutiquecoupon/router',
url,
data
})
},
/** 分页查询用户券列表(待核销、已核销) */
getCustomerCouponList(data) {
data.method = 'scrm.api.boutiquecoupon.wework.customerCoupon.page'
data.pageSize = 10
return window.$HTTP({
url,
data
})
},
}
\ No newline at end of file \ No newline at end of file
const url = '/rop-scrm-coupon/router'
const pageSize = 10
export default {
/**商城优惠券列表 */
getMerchantCouponList(data) {
// data.method = 'scrm.api.coupon.list.merchant'
data.method = 'scrm.wechat.activity.coupon.list'
data.pageSize = pageSize
data.validType = 'valid'
data.discountTypes = [2,3,4]
return window.$HTTP({
url,
data
})
},
/** 获取优惠卷分享链接 */
getCouponShared(data) {
data.method = 'scrm.api.coupon.share'
return window.$HTTP({
url,
data
})
},
/** 已经核销列表 */
getVerificationList(data) {
data.method = 'scrm.api.coupon.verification.code.verification.list'
data.pageSize = pageSize
return window.$HTTP({
url,
data
})
},
/** 查询已领取 未核销 */
getUserCouponList(data) {
data.method = 'scrm.api.coupon.user.list.merchant'
data.pageSize = pageSize
return window.$HTTP({
url,
data
})
},
/** 根据核销码查询卷信息 */
scan(data) {
data.method = 'scrm.api.coupon.verification.code.scan'
return window.$HTTP({
url,
data
})
},
/** 核销核销码 */
verificationCode(data) {
data.method = 'scrm.api.coupon.verification.code.verification'
return window.$HTTP({
url,
data
})
},
}
\ No newline at end of file \ No newline at end of file
const url = '/rop-scrm-equity/router'
export default {
/**套餐分页查询 */
getEquityList (pageNum) {
let data = {
method: 'scrm.api.equity.package.info.list.with.page',
pageSize: 10,
state: 1,
pageNum
}
return window.$HTTP({
url,
data
})
},
/**套餐详情 */
getEquityDetail (data) {
data.method = 'scrm.api.equity.main.page.package.detail.get'
return window.$HTTP({
url,
data
})
},
/** 获取套餐分享链接 */
getEquityShared (data) {
data.method = 'scrm.api.equity.package.info.share'
return window.$HTTP({
url,
data
})
},
}
\ No newline at end of file \ No newline at end of file
const url = '/rop-scrm-coupon/router'
const pageSize = 10
export default {
/**根据条件获取定向礼包列表(企微) */
getGiftList (data) {
data.method = 'scrm.api.coupon.weChat.directional.gift.list'
data.pageSize = pageSize
return window.$HTTP({
url,
data
})
},
/** 获取审批中列表 */
getInApproveGiftList (data) {
data.method = 'scrm.api.coupon.weChat.directional.gift.approve.in.list'
data.pageSize = pageSize
return window.$HTTP({
url,
data
})
},
/** 获取审批中列表 */
toApproveById (data) {
data.method = 'scrm.api.coupon.directional.gift.commit.approve'
return window.$HTTP({
url,
data
})
},
/** 根据id删除定向礼包 */
deleteGift (data) {
data.method = 'scrm.api.coupon.directional.gift.delete'
return window.$HTTP({
url,
data
})
},
/**根据id获取定向礼包详情(企微) */
getGiftDetail (id) {
let data = {
method: 'scrm.api.coupon.weChat.directional.gift.detail',
id
}
return window.$HTTP({
url,
data
})
},
/**定向礼包专用优惠券列表(嘀加后台和企微) */
getCouponList (data) {
data.method = 'scrm.api.coupon.directional.gift.coupon.list'
data.pageSize = 9999
return window.$HTTP({
url,
data
})
},
/**创建或修改礼包,修改时礼包id必传 */
createOrupdataGift (data) {
data.method = 'scrm.api.coupon.directional.gift.create'
return window.$HTTP({
url,
data
})
},
/**根据定向礼包id获取二维码路径 */
createQr (data) {
data.method = 'scrm.api.coupon.directional.gift.qr.code'
return window.$HTTP({
url,
data
})
}
}
\ No newline at end of file \ No newline at end of file
...@@ -6,24 +6,22 @@ ...@@ -6,24 +6,22 @@
* @LastEditors: limin * @LastEditors: limin
* @LastEditTime: 2021-06-17 18:23:27 * @LastEditTime: 2021-06-17 18:23:27
*/ */
import ssoApi from './ssoApi' // import ssoApi from './ssoApi'
import liveApi from './liveApi' // import liveApi from './liveApi'
import couponApi from './couponApi' // import couponApi from './couponApi'
import activityApi from './activityApi' // import activityApi from './activityApi'
import wxConfig from './wxConfig' // // import wxConfig from './wxConfig'
import shopmallApi from './shopmallApi' // import shopmallApi from './shopmallApi'
import boutiquecouponApi from './boutiquecouponApi' // import boutiquecouponApi from './boutiquecouponApi'
import equityApi from './equityApi' // import equityApi from './equityApi'
import giftApi from './giftApi' // import giftApi from './giftApi'
export {
ssoApi,
couponApi,
wxConfig,
shopmallApi,
activityApi,
liveApi,
boutiquecouponApi,
equityApi,
giftApi
}
\ No newline at end of file \ No newline at end of file
export {} // ssoApi,
// couponApi,
// // wxConfig,
// shopmallApi,
// activityApi,
// liveApi,
// boutiquecouponApi,
// equityApi,
// giftApi
const url = '/rop-scrm-live/router'
export default {
/** 分页查询活动 */
getLiveList(pageNum) {
let data = {
method: 'scrm.api.live.live.room.list',
pageSize: 10,
pageNum
}
return window.$HTTP({
url,
data,
})
},
getShared(data) {
data.method = 'scrm.api.live.get.shared.code'
return window.$HTTP({
url,
data
})
},
}
\ No newline at end of file \ No newline at end of file
/*
* @Author: limin
* @Date: 2019-08-26 18:02:41
* @Last Modified by: chenwq
* @Last Modified time: 2021-06-30 14:30:41
*/
import axios from './axios'
import sign from './sign'
import RequestMethods from './request.methods'
// import util from '@/libs/util.js'
import { baseConfig } from '@/main'
const request = (params = {}, method = RequestMethods.GET, noSignAttr = [], options) => {
// console.log(baseConfig)
// params.source = 'glsx'
console.log(params)
// params.appKey = 'd7ffc3346fc9a45bccaaa35300d59022'
params.appKey = baseConfig?.axios?.appkey
// clg
// console.log(params.appKey)
// params.appKey = window.location.href.includes('dj.glsx.com.cn')
// ? 'd7ffc3346fc9a45bccaaa35300d59022'
// : '48e5e13229b82c1b4e6e8c96151f0637'
params.timestamp = new Date().getTime()
params.v = '1.0.0'
params.format = 'json'
params.locale = 'zh_CN'
// if (params.method !== 'dj.api.user.login') {
// params.sessionId = util.cookies.get('token')
// }
/**
* mock - url = params.method
* 调后端接口 - url = ''
*/
const path = '/rop-dj-car-boutique/router'
// baseConfig.axios.baseURL + params.method
const url = `${baseConfig.axios.baseURL}${path}?method=${params.method}`
console.log(url)
// console.log(url)
/**
* 调后端接口,请使用以下代码。
*/
//
// baseURL: process.env.VUE_APP_API + '?method=' + params.method,
var reqData = method === RequestMethods.POST ? { baseURL: '/', data: sign(params, noSignAttr) } : { params: sign(params, noSignAttr) }
reqData = reqData = Object.assign(reqData, options, {})
// console.log(method === RequestMethods.POST)
// console.log(url)
// console.log(options)
// console.log(reqData)
return axios({
url,
method,
...reqData
})
/**
* mock,请使用以下代码。
*/
// return axios({
// url,
// method,
// params: sign(params, noSignAttr)
// })
}
export default request
/*
* @Author: limin
* @Date: 2019-08-26 18:01:59
* @Last Modified by: limin
* @Last Modified time: 2019-08-26 18:02:32
*/
const RequestMethods = {
POST: 'post',
GET: 'get',
PUT: 'put',
DELETE: 'delete'
}
export default RequestMethods
const url = '/rop-scrm-shopmall/router'
export default {
/** 获取门店商品列表 */
getGoodsList (currentPage) {
let data = {
method: 'scrm.api.shopmall.goods.wework.page',
pageSize: 10,
currentPage,
needActivityInfo: true
}
return window.$HTTP({
url,
data
})
},
/**获取商品海报 */
getGoodsPoster (data) {
data.method = 'scrm.api.shopmall.goods.wework.posterUrl'
return window.$HTTP({
url,
data
})
},
/** 获取商品链接 */
getGoodsLink (data) {
data.method = 'scrm.api.shopmall.goods.wework.url'
return window.$HTTP({
url,
data
})
},
/** 获取商品海报企业微信素材mediaId */
getGoodsPosterMediaId (data) {
data.method = 'scrm.api.shopmall.goods.wework.posterWorkWxMediaId'
return window.$HTTP({
url,
data
})
},
/** 分页查询商品订单核销列表(待核销、已核销用查询参数区分) */
getGoodsVerficationList (data = {}) {
data.method = 'scrm.api.shopmall.wework.order.verfication.page'
data.pageSize = 10
return window.$HTTP({
url,
data
})
},
/**根据商城订单核销码获取商城订单详情以备核销 */
getGoodsVerficationDetail (verificationCode) {
let data = {
method: 'scrm.api.shopmall.wework.order.detail.toVerfication',
verificationCode: verificationCode
}
return window.$HTTP({
url,
data
})
},
/** 商品订单核销 */
verficationGoods (verificationCode) {
let data = {
method: 'scrm.api.shopmall.wework.order.verfication',
verificationCode: verificationCode
}
return window.$HTTP({
url,
data
})
},
/**查看商品订单详情 */
getGoodsDetail (orderCode) {
let data = {
method: 'scrm.api.shopmall.weapp.order.detail',
orderCode
}
return window.$HTTP({
url,
data
})
}
}
/*
* @Author: limin
* @Date: 2019-08-26 18:02:49
* @Last Modified by: chenwq
* @Last Modified time: 2021-06-18 10:04:32
*/
import sha1 from 'sha1'
import qs from 'qs'
import { baseConfig } from '@/main'
import { util } from '@/utils'
console.log(util)
// // 等后面再处理
// console.log(baseConfig)
// // const secret =
// // window.location.href.includes('dj.glsx.com.cn') ||
// // window.location.href.includes('dj.beta.glsx.com.cn')
// // ? '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
// // : 'c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b'
const sign = (params, noSignAttr = []) => {
// console.log(baseConfig)
// 写里面取值解决一开始导入就被确定值导致后面无法改动
const secret = baseConfig?.axios?.secret
// console.log(secret)
delete params.sign
var objStr = qs.stringify(util.deepClone(params), {
arrayFormat: 'indices',
allowDots: true,
encodeValuesOnly: true
})
var objVal = objStr.split('&')
var realObj = {}
objVal.forEach(item => {
const idx = item.indexOf('=')
realObj[item.split('=')[0]] = decodeURIComponent(item.slice(idx + 1))
})
const keys = Object.keys(realObj).sort()
var str = []
var obj = null
for (const key in realObj) {
obj = realObj[key]
if (obj === null) {
obj = ''
} else if (typeof obj === 'object') {
obj = JSON.stringify(obj)
}
realObj[key] = obj
}
keys.forEach(e => {
!noSignAttr.includes(e) && str.push(e + realObj[e])
})
realObj.sign = sha1(secret + str.join('') + secret).toUpperCase()
return realObj
}
export default sign
const url = '/rop-scrm-sso/router'
const returnAll = true
export default {
/**OAuth2授权登陆 */
login(data) {
data.method = 'scrm.api.sso.ww.oauth.login'
data.productCode = 'PC00025'
return window.$HTTP({
url,
data,
returnAll
})
},
/** 选择登录账号 */
selectAccount(data) {
data.method = 'scrm.api.sso.user.login.select'
return window.$HTTP({
url,
data,
returnAll
})
}
}
\ No newline at end of file \ No newline at end of file
.gift-layout {
padding: 10px 16px 106px;
.box {
background: #ffffff;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
border-radius: 4px;
margin-bottom: 10px;
.item {
display: flex;
align-items: center;
min-height: 59px;
padding: 0 16px;
font-size: 14px;
border-bottom: 1px solid rgba(195, 195, 195, 0.3);
&:last-of-type {
border-bottom: none;
}
}
.label {
color: #666666;
width: 80px;
flex-shrink: 0;
span {
display: block;
font-size: 10px;
transform: translateX(-7px);
}
}
.value {
color: #333;
width: calc(100% - 90px);
text-align: right;
margin-left: auto;
span {
color: #f1515c;
}
}
.detail-box {
padding: 0 12px 8px 11px;
.detail {
border-bottom: 1px solid rgba(195, 195, 195, 0.3);
&:last-of-type {
border-bottom: none;
}
&-item {
border-bottom: 1px solid rgba(195, 195, 195, 0.3);
font-size: 12px;
color: #333333;
padding: 12px 5px;
position: relative;
&:last-of-type {
border-bottom: none;
}
.name {
font-size: 14px;
&-tips {
margin-left: 8px;
width: 46px;
height: 16px;
background: #CBCBCB;
border-radius: 4px;
font-size: 10px;
color: #FFFFFF;
}
}
.num {
color: #282829;
}
.price {
color: #f1515c;
margin-left: auto;
}
}
&-title {
margin: 11px 0 0 5px;
height: 28px;
background: rgba(57, 117, 198, 0.15);
border-radius: 14px;
font-size: 14px;
color: #3975c6;
padding: 0 12px;
display: inline-flex;
}
.del {
position: absolute;
top: 12px;
right: 2px;
}
.coupon-disabled {
color: #999999;
.num {
color: #999999;
}
.price {
color: #999999;
}
}
}
}
}
.readonly-box {
padding: 10px 16px 20px;
color: #333333;
.title {
font-size: 14px;
margin-bottom: 20px;
color: #666666;
}
.item {
min-height: auto;
padding: 0;
}
}
.user-info {
padding: 0 12px;
height: 84px;
border-bottom: 1px solid rgba(195, 195, 195, 0.3);
font-weight: 600;
font-size: 16px;
color: #333333;
.icon {
width: 44px;
height: 44px;
margin-right: 12px;
flex-shrink: 0;
}
}
.btn {
position: fixed;
bottom: 16px;
width: 175px;
height: 36px;
background: #3975c6;
box-shadow: 0px 2px 4px 0px rgba(57, 117, 198, 0.2);
border-radius: 21px;
color: #fff;
font-size: 14px;
box-sizing: border-box;
transition: all .5s;
}
.create {
width: 343px;
height: 42px;
}
.disabled-btn {
background: #A2A2A2;
}
.add-box {
height: 56px;
.add-btn {
width: 60px;
height: 24px;
background: #3975C6;
box-shadow: 0px 2px 6px 2px rgba(57, 117, 198, 0.11);
border-radius: 11px;
border: 1px solid #3975C6;
}
}
.radio-box {
color: #333;
font-size: 12px;
.title {
margin-bottom: 0;
}
.radio-item {
margin-top: 20px;
padding-left: 12px;
.radio-input {
margin-left: 16px;
padding: 10px 0 4px 0;
border-bottom: 1px solid #F8F8F8;
.van-field {
padding: 0;
font-size: 12px;
}
}
}
}
.textarea {
.title {
margin-bottom: 8px;
}
.van-field {
padding: 8px;
border: 1px solid #F1F1F1;
box-sizing: border-box;
height: 100px;
}
.van-field--min-height .van-field__control {
height: 82px;
}
}
}
.radio {
width: 12px;
height: 12px;
border: 1px solid #979797;
box-sizing: border-box;
border-radius: 100%;
margin-right: 4px;
transition: all .2s;
}
.radio-active {
border-color: #3975C6;
display: flex;
justify-content: center;
align-items: center;
&::after {
content: '';
display: block;
background: #3975C6;
box-shadow: 0px 2px 6px 2px rgba(57, 117, 198, 0.11);
border: 1px solid #3975C6;
box-sizing: border-box;
border-radius: 100%;
animation: radioFrames .2s forwards;
}
}
@keyframes radioFrames {
0% {
width: 1px;
height: 1px;
}
100% {
width: 6px;
height: 6px;
}
}
\ No newline at end of file \ No newline at end of file
/* eslint-disable eqeqeq */
/* /*
* @Descripttion: * @Descripttion:
* @version: * @version:
...@@ -15,7 +16,7 @@ import App from './App.vue' ...@@ -15,7 +16,7 @@ import App from './App.vue'
import router from './router' import router from './router'
import store from './store' import store from './store'
import api from './api' import api from './api'
import { fetchConfig, cfg } from '@/config' // import { fetchConfig, cfg } from '@/config'
import '@/assets/css/index.scss' import '@/assets/css/index.scss'
import { bus, tools, store as local, util } from './utils' import { bus, tools, store as local, util } from './utils'
import './utils/util' import './utils/util'
...@@ -37,25 +38,85 @@ Vue.prototype.to = function (name, params) { ...@@ -37,25 +38,85 @@ Vue.prototype.to = function (name, params) {
// import 'lib-flexible/flexible.js' // import 'lib-flexible/flexible.js'
import VConsole from 'vconsole' import VConsole from 'vconsole'
var baseConfig = {
const isMock = ['prod','production'].includes(process.env.NODE_ENV) axios: {
fetchConfig(!isMock).then(res => { appkey: 'd7ffc3346fc9a45bccaaa35300d59022',
// 从配置服务器获取动态配置 secret: '4bc07f8868374c49a4661d603377e3106fc9a45bccaaa353'
// 设置 js中可以访问 $cdn }
Vue.use(cfg) }
window.$fetchConfig = res // const isMock = ['prod', 'production'].includes(process.env.NODE_ENV)
if (res.vconsole) new VConsole() // 使用fetch 解决axios提前实例化导致sign里面的secret不能通过配置中心动态获取
fetch('http://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=dj-car-life-alipay-config')
/**登录过期 重新登录 */ .then(
window.reLogin = () => { response => {
console.log('重新登录') // 处理http响应
util.clearSessionId() return response.json()
store.dispatch('navigation') },
error => {
// 处理错误
console.log(error)
} }
window.vm = new Vue({ )
el: '#app', .then(response => {
console.log(response)
const { code, data } = response
code == '200' && ((baseConfig = data), (window.$fetchConfig = data))
// window.$fetchConfig = res
// console.log('data', data)
// if (data.vconsole)
new VConsole()
new Vue({
router, router,
store, store,
render: h => h(App) // i18n,
render: h => {
// data.axios.baseURL =
// 'http://dj.test.glsx.com.cn/rop-dj-smartcarlife/router'
Vue.prototype.baseConfig = data
return h(App)
}
// created () {
// 处理路由 得到每一级的路由设置
// this.$store.commit('d2admin/page/init', frameInRoutes)
// 设置顶栏菜单 (暂时不需要)
// this.$store.commit('d2admin/menu/headerSet', menuHeader)
// 设置侧边栏菜单 (TODO 进行过滤)
// this.$store.commit('d2admin/menu/asideSet', menuAside)
// 初始化菜单搜索功能
// this.$store.commit('d2admin/search/init', menuHeader)
// },
// created() {
// // 系统配置
// Vue.config.devtools = true
// // 展示系统信息
// this.$store.commit('d2admin/releases/versionShow')
// // 用户登录后从数据库加载一系列的设置
// this.$store.dispatch('d2admin/account/load')
// // 获取并记录用户 UA
// this.$store.commit('d2admin/ua/get')
// // 初始化全屏监听
// this.$store.dispatch('d2admin/fullscreen/listen')
// },
// mounted() {}
}).$mount('#app')
}) })
}) // fetchConfig(!isMock).then(res => {
// // 从配置服务器获取动态配置
// // 设置 js中可以访问 $cdn
// Vue.use(cfg)
// window.$fetchConfig = res
// if (res.vconsole) new VConsole()
// /** 登录过期 重新登录 */
// // window.reLogin = () => {
// // console.log('重新登录')
// // // util.clearSessionId()
// // }
// window.vm = new Vue({
// el: '#app',
// router,
// store,
// render: h => h(App)
// })
// })
export { baseConfig }
const discountType = {
1: '满减',
2: '折扣',
3: '代金',
4: '兑换',
5: '购车代金',
6: '商品折扣',
7: '门店服务'
}
export default {
data() {
return {
discountType,
discountEnum: {
1: '满减券',
2: '折扣券',
3: '代金券',
4: '兑换券',
5: '购车代金券',
6: '商品折扣券',
7: '门店服务'
},
}
},
mounted() {
window.$discountType = discountType
},
methods: {
}
}
\ No newline at end of file \ No newline at end of file
export const setApproveParam = res =>{
const {approveTemplateId, approveNo, name, remarkName, anticipatedCost, coupons, giveReason} = res
let couponStr = ''
coupons.forEach(item => {
couponStr = couponStr + `${item.couponName}x${item.couponAmount}, 预估成本${(item.couponAnticipatedCost*item.couponAmount/100).toFixed(2)}元\n`
})
const param = {
"oaType": "10001",
"templateId": approveTemplateId,
"thirdNo": approveNo,
"extData": {
'fieldList': [
{
'title': '礼包名称',
'type': 'text',
'value': name,
},
{
'title': '备注名称',
'type': 'text',
'value': remarkName,
},
{
'title': '预估成本',
'type': 'text',
'value': (anticipatedCost/100).toFixed(2) + '元',
},
{
'title': '礼包明细',
'type': 'text',
'value': couponStr,
},
{
'title': '赠送原因',
'type': 'text',
'value': giveReason==null ? '': giveReason ,
},
]
}
}
console.log(param,'param')
return param;
}
\ No newline at end of file \ No newline at end of file
import shareMixin from './shareMixin' // import shareMixin from './shareMixin'
import pageMixin from './pageMixin' // import pageMixin from './pageMixin'
import discountTypeMixin from './discountTypeMixin' // import discountTypeMixin from './discountTypeMixin'
export {
shareMixin,
pageMixin,
discountTypeMixin
}
\ No newline at end of file \ No newline at end of file
// export {
// shareMixin,
// pageMixin,
// discountTypeMixin
// }
export default {
data () {
return {
tabIndex: 0,
pageNum: 1,
list: [],
total: 0,
flag: false,
updata: new Date().getTime()
}
},
mounted () {
let { tabIndex } = this.getQuery()
if (tabIndex) {
this.tabIndex = Number(tabIndex)
this.updata = new Date().getTime()
this.init()
return
}
if (this.$route.meta.isTab) this.init()
},
methods: {
init () {
this.showLoading()
this.getList(this.pageNum)
},
change (index) {
this.tabIndex = index
this.clearData()
},
clearData () {
this.flag = false
this.pageNum = 1
this.list = []
if (this.$refs.scrollView) this.$refs.scrollView.finished = false
this.init()
},
onReachBottom () {
let { total, pageNum, list } = this
this.$refs.scrollView.loading = false
if (list.length == total) {
this.$refs.scrollView.finished = true
return
}
if (Math.ceil(total / 10) > pageNum) {
this.pageNum = pageNum + 1
this.init()
} else {
this.$refs.scrollView.finished = true
}
}
}
}
\ No newline at end of file \ No newline at end of file
import { couponApi, wxConfig } from '@/api'
export default {
data () {
return {
entry: 'normal'
}
},
mounted () {
if (this.$route.meta.isTab || this.$route.meta.isIndex) this.wxInit()
// wxConfig
// .createMiniprogramUrlLink({
// path: 'packageEquity/pages/active/active',
// appId: 'wxfe82b8d65d07808f',
// query: '?ss=ss',
// envVersion: 'release'
// })
// .then(url => {
// console.log(url)
// })
},
methods: {
wxInit () {
let _this = this
wxConfig.init(['shareAppMessage', 'sendChatMessage', 'getCurExternalContact', 'getContext']).then(() => {
wxConfig.getContext().then(({ entry }) => {
_this.$parent.entry = entry
_this.entry = entry
})
})
},
showShareModel (i = {}) {
let {
tabIndex,
$route: { name }
} = this
if (name != 'merchant') {
if (tabIndex == 0 && i.remainAmount < 1) return
if (tabIndex == 1 && i.residueAmount < 1) return
}
wxConfig
.getCurExternalContact()
.then(res => {
console.log('当前外部联系人', res)
i.is_contact = res
this.sendMessage(i)
})
.catch(() => {
this.sendMessage(i)
})
},
sendMessage (i) {
const { shopmall_appid } = window.$fetchConfig
let { merchantId, merchantName, userName, sapCode, uuid } = this.getLocalStorage('dj_scrm_userInfo')
console.log(this.getLocalStorage('dj_scrm_userInfo'))
let { tabIndex, entry } = this
let { name } = this.$route
let { userId, id, couponName, activityName, packageName, goodsName, goodsImage, discountType } = i
let query = `merchantId=${merchantId}&shareTime=${Date.now()}`
if (sapCode) query = `${query}&storeCode=${sapCode}`
const entryType = entry != 'normal'
this.showLoading()
if (name === 'coupon') { /**卡券 */
let desc = '您的专属服务顾问为您发来了优惠券,请点击领取~'
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-yh-10004.png'
if (tabIndex == 0) {
let path = 'packageMine/pages/boutique/gift/gift'
query = `id=${id}&userId=${userId}&employName=${this.toUnicode(i.employeeName)}&${query}`
if (entryType) this.sendChatMessage({
appid: shopmall_appid,
title: couponName,
imgUrl,
page: `/${path}.html?${query}`
})
else wxConfig
.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid
})
.then(url => {
this.shareAppMessage(url, desc, couponName, imgUrl)
})
} else {
let path = 'packageMall/pages/coupon/coupon'
query = `couponId=${id}&${query}&issueName=${this.toUnicode(userName)}&issueDate=${new Date().getTime()}&shareSource=1&shareStaffName=${this.toUnicode(userName)}&shareStaffUuid=${uuid}`
this.couponShare(i, url => {
if (entryType) this.sendChatMessage({
appid: shopmall_appid,
title: `${couponName}(${window.$discountType[discountType]}券)`,
imgUrl,
page: `/${path}.html?${query}`
})
else wxConfig
.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid
})
.then(url => {
this.shareAppMessage(url, desc, couponName, imgUrl)
})
})
}
} else if (name === 'activity') { /**活动 */
if (tabIndex == 0) {
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-ms-10004.png'
let path = 'packageMall/pages/detail/detail'
query = `isActivity=true&id=${id}&${query}&shareStaffName=${this.toUnicode(userName)}&shareStaffUuid=${uuid}`
if (entryType) this.sendChatMessage({
appid: shopmall_appid,
title: activityName,
imgUrl,
page: `/${path}.html?${query}`
})
else wxConfig
.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid
})
.then(url => {
this.shareAppMessage(url, '您有一个秒杀活动可参加', activityName, imgUrl)
})
} else {
/**直播 */
}
} else { /**店铺 */
if (tabIndex == 0) {
let path = 'pages/tab/index/index'
const imgUrl = 'https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/miniprogram-cover.jpg'
if (entryType) this.sendChatMessage({
appid: shopmall_appid,
title: merchantName,
imgUrl,
page: `/${path}.html?${query}`
})
else wxConfig
.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid
})
.then(url => {
this.shareAppMessage(url, '', merchantName, imgUrl)
})
} else if (tabIndex == 1) {
let path = 'packageEquity/pages/package/package'
let imgUrl = 'http://img01.glsx.com.cn/upload/biz/dracMini-qy-10004.png'
query = `id=${id}&${query}&shareStaffName=${this.toUnicode(userName)}&shareStaffUuid=${uuid}`
if (entryType) this.sendChatMessage({
appid: shopmall_appid,
title: packageName,
imgUrl,
page: `/${path}.html?${query}`
})
else wxConfig
.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid
})
.then(url => {
this.shareAppMessage(url, '您的专属客服顾问为您发来了会员套餐,点击查看哦', packageName, imgUrl)
})
} else {
let path = 'packageMall/pages/detail/detail'
query = `id=${id}&${query}&shareStaffName=${this.toUnicode(userName)}&shareStaffUuid=${uuid}`
if (entryType) this.sendChatMessage({
appid: shopmall_appid,
title: goodsName,
imgUrl: goodsImage,
page: `/${path}.html?${query}`
})
else wxConfig
.createMiniprogramUrlLink({
path,
query,
appId: shopmall_appid
})
.then(url => {
this.shareAppMessage(url, '', goodsName, goodsImage)
})
}
}
},
sendChatMessage (params) {
wxConfig
.sendChatMessage({
msgtype: 'miniprogram',
miniprogram: params,
enterChat: false
})
.then(() => {
this.hideLoading()
})
.catch(err => {
console.log('当前会话', err)
this.hideLoading()
})
},
shareAppMessage (link, desc, title, imgUrl) {
wxConfig
.shareAppMessage({
title,
desc,
link,
imgUrl
})
.then(() => {
this.hideLoading()
})
.catch(() => {
this.hideLoading()
})
},
toUnicode (chineseStr = '') {
let unicodeStr = ''
for (let i = 0, iLength = chineseStr.length; i < iLength; i++) {
unicodeStr += '@' + chineseStr.charCodeAt(i).toString(16)
}
return unicodeStr
},
couponShare (item, callBack) {
let { is_contact, id } = item
let obj = {
couponId: id,
shareType: 1
}
if (is_contact) obj.userList = [
{
userId: is_contact
}
]
else obj.shareType = 0
couponApi.getCouponShared(obj).then(res => {
callBack(res.url)
})
}
}
}
...@@ -42,11 +42,11 @@ router.beforeEach((to, from, next) => { ...@@ -42,11 +42,11 @@ router.beforeEach((to, from, next) => {
store.commit('SET_LAST_PATH', to.name) store.commit('SET_LAST_PATH', to.name)
/* 路由发生变化修改页面背景色 */ /* 路由发生变化修改页面背景色 */
if (to.meta.backgroundColor) document.documentElement.style.backgroundColor = to.meta.backgroundColor if (to.meta.backgroundColor) document.documentElement.style.backgroundColor = to.meta.backgroundColor
if (to.matched.some(recode => recode.meta.noAuth)) { // if (to.matched.some(recode => recode.meta.noAuth)) {
store.state.app.showWindow = true // store.state.app.showWindow = true
} else { // } else {
store.dispatch('navigation') // store.dispatch('navigation')
} // }
next() next()
}) })
......
const pages = { // const pages = {
coupon: [{ // coupon: [{
name: 'index', // name: 'index',
meta: { // meta: {
isTab: true // isTab: true
} // }
}, // },
{ // {
name: 'verificationList', // name: 'verificationList',
meta: { // meta: {
title: '核销列表', // title: '核销列表',
keepAlive: true // keepAlive: true
} // }
}, // },
{ // {
name: 'verificationDetail', // name: 'verificationDetail',
meta: { // meta: {
title: '核销详情', // title: '核销详情',
keepAlive: true // keepAlive: true
} // }
}, // },
{ // {
name: 'goodsVerification', // name: 'goodsVerification',
meta: { // meta: {
title: '核销订单', // title: '核销订单',
keepAlive: true // keepAlive: true
} // }
} // }
], // ],
activity: [ // activity: [
// {
// name: 'index',
// meta: {
// isTab: true,
// keepAlive: true,
// backgroundColor: '#F7F7F7'
// },
// }
// ],
// merchant: [
// {
// name: 'index',
// meta: {
// keepAlive: true,
// isIndex: true,
// backgroundColor: '#F7F7F7',
// title: '店铺中心'
// }
// }
// ],
// gift:[
// {
// name:'index',
// meta: {
// title:'定向礼包',
// backgroundColor: '#F7F7F7'
// }
// },
// {
// name:'detail',
// meta: {
// title:'定向礼包',
// backgroundColor: '#F7F7F7'
// }
// },
// {
// name:'create',
// meta: {
// title:'定向礼包',
// backgroundColor: '#F7F7F7'
// }
// }
// ]
// }
const routes = [
// {
// path:'/',
// redirect: '/coupon'
// }
// 登录
{ {
path: '/index',
name: 'index', name: 'index',
meta: { meta: 'layout',
isTab: true, // redirect: {
keepAlive: true, // name: 'index'
backgroundColor: '#F7F7F7' // },
// component: import('@/views/layouts/index')
component: () => import('@/views/layouts')
}, },
}
],
merchant: [
{ {
name: 'index', // path: '/ailpay',
meta: { path: '/',
keepAlive: true, redirect: { name: 'index' },
isIndex: true, // name: 'index',
backgroundColor: '#F7F7F7', component: () => import('@/views/layouts'),
title: '店铺中心' children: [
}
}
],
gift:[
{
name:'index',
meta: {
title:'定向礼包',
backgroundColor: '#F7F7F7'
}
},
{ {
name:'detail', // 支付页面
meta: { path: '/alipay',
title:'定向礼包', name: 'alipay',
backgroundColor: '#F7F7F7' component: () => import('@/views/alipay')
}
},
{
name:'create',
meta: {
title:'定向礼包',
backgroundColor: '#F7F7F7'
}
} }
] ]
}
let routes = [
{
path:'/',
redirect: '/coupon'
} }
] ]
const keepAlives = [] // const keepAlives = []
Object.keys(pages).map(parent => { // Object.keys(pages).map(parent => {
pages[parent].map(val => { // pages[parent].map(val => {
let childrenPath = `${parent}/${val.name}` // let childrenPath = `${parent}/${val.name}`
let { meta } = val // let { meta } = val
const path = `/${val.name == 'index' ? parent : childrenPath}` // const path = `/${val.name == 'index' ? parent : childrenPath}`
const name = val.name == 'index' ? parent : childrenPath.replace('/', '.') // const name = val.name == 'index' ? parent : childrenPath.replace('/', '.')
if (meta && meta.keepAlive) keepAlives.push(name) // if (meta && meta.keepAlive) keepAlives.push(name)
let route = { // let route = {
component: resolve => require([`views/${childrenPath}.vue`], resolve), // component: resolve => require([`views/${childrenPath}.vue`], resolve),
path, // path,
name, // name,
meta // meta
} // }
routes.push(route) // routes.push(route)
}) // })
}) // })
console.log(routes) // console.log(routes)
export const keeps = keepAlives // export const keeps = keepAlives
export default routes export default routes
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
*/ */
import { ssoApi } from '@/api' import { ssoApi } from '@/api'
import { store, util } from 'utils' import { store, util } from 'utils'
import { Http } from 'glsx-common' // import { Http } from 'glsx-common'
import { Notify } from 'vant' import { Notify } from 'vant'
const state = { const state = {
pageMeta: '', pageMeta: '',
...@@ -52,116 +52,116 @@ const actions = { ...@@ -52,116 +52,116 @@ const actions = {
}, },
removeKeep({ commit }, names) { removeKeep({ commit }, names) {
commit('REMOVE_KEEP', names) commit('REMOVE_KEEP', names)
},
login({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
// 以下是 本地调试
if (process.env.NODE_ENV == 'development') {
const code = getParams('code')
if (code) {
const { corpId } = util.getLocalStorage('dj_scrm_corpId')
ssoApi
.login({
code,
corpId
})
.then(({ code, data, message }) => {
let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
route = route.replace('.', '/')
if (code == '0') {
if (data.loginList.length) {
if (data.loginList.length > 1) {
let userInfo = data.loginList[0]
let { merchantId, accountName } = userInfo
let loginAccount = accountName
ssoApi
.selectAccount({
loginAccount,
merchantId,
loginToken: data.loginToken,
loginSource: 'WW',
loginType: 3
})
.then(res => {
util.setLocalStorage('dj_scrm_userInfo', res.data)
util.setSessionId(res.data.sessionId)
dispatch('registerHttp', res.data.sessionId)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
})
} else {
let [userInfo] = data.loginList
util.setLocalStorage('dj_scrm_userInfo', userInfo)
util.setSessionId(userInfo.sessionId)
dispatch('registerHttp', userInfo.sessionId)
// 只有一个账号 history.back()
console.log(`${redirectUrl}${route}`)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
}
} else {
/**没有账号 */
Notify('没有账号')
// window.location.href = `${url}common/nothing`
}
} else {
/**账号过期 (暂时没有字段判断是否过期) */
Notify(message)
// window.location.href = `${url}common/overdue`
}
})
} else {
util.showLoading()
let appid = getParams('corpId') //从链接获取
let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'ww7ee69c648ae1b7e6'
util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// 'ww657a2d4ae89a4424'
const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
}
} else {
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
const { baseURL } = window.$fetchConfig.request
let url = `${baseURL}/dj-scrm-wx-work-main/#/`
window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${storage_corpId.corpId}`
}
},
navigation({ dispatch }) {
let { sessionId, corpId } = getParams()
const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
if (!corpId) corpId = storage_corpId && storage_corpId.corpId
if (corpId && storage_corpId) {
if (corpId != storage_corpId.corpId) {
util.removeLocalStorage('dj_scrm_userInfo')
util.clearSessionId()
}
}
util.setLocalStorage('dj_scrm_corpId', { corpId })
const storage_sessionId = util.getSessionId()
if (sessionId || storage_sessionId) {
state.showWindow = true
util.setSessionId(sessionId || storage_sessionId)
dispatch('registerHttp', sessionId || storage_sessionId)
} else {
util.showLoading()
dispatch('registerHttp')
dispatch('login')
return
}
state.showWindow = true
},
registerHttp({}, sessionId = '') {
window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
} }
// login({ dispatch }) {
// let [redirectUrl] = window.location.href.split('?')
// // 以下是 本地调试
// if (process.env.NODE_ENV == 'development') {
// const code = getParams('code')
// if (code) {
// const { corpId } = util.getLocalStorage('dj_scrm_corpId')
// ssoApi
// .login({
// code,
// corpId
// })
// .then(({ code, data, message }) => {
// let route = state.lastPath == 'coupon' ? '' : state.lastPath || ''
// route = route.replace('.', '/')
// if (code == '0') {
// if (data.loginList.length) {
// if (data.loginList.length > 1) {
// let userInfo = data.loginList[0]
// let { merchantId, accountName } = userInfo
// let loginAccount = accountName
// ssoApi
// .selectAccount({
// loginAccount,
// merchantId,
// loginToken: data.loginToken,
// loginSource: 'WW',
// loginType: 3
// })
// .then(res => {
// util.setLocalStorage('dj_scrm_userInfo', res.data)
// util.setSessionId(res.data.sessionId)
// dispatch('registerHttp', res.data.sessionId)
// state.showWindow = true
// window.location.replace(`${redirectUrl}#/${route}`)
// })
// } else {
// let [userInfo] = data.loginList
// util.setLocalStorage('dj_scrm_userInfo', userInfo)
// util.setSessionId(userInfo.sessionId)
// dispatch('registerHttp', userInfo.sessionId)
// // 只有一个账号 history.back()
// console.log(`${redirectUrl}${route}`)
// state.showWindow = true
// window.location.replace(`${redirectUrl}#/${route}`)
// }
// } else {
// /**没有账号 */
// Notify('没有账号')
// // window.location.href = `${url}common/nothing`
// }
// } else {
// /**账号过期 (暂时没有字段判断是否过期) */
// Notify(message)
// // window.location.href = `${url}common/overdue`
// }
// })
// } else {
// util.showLoading()
// let appid = getParams('corpId') //从链接获取
// let dj_scrm = util.getLocalStorage('dj_scrm_corpId')
// if (!appid) appid = (dj_scrm && dj_scrm.corpId) || 'ww7ee69c648ae1b7e6'
// util.setLocalStorage('dj_scrm_corpId', { corpId: appid })
// // 'ww657a2d4ae89a4424'
// const wxUrl = 'https://open.weixin.qq.com/connect/oauth2/authorize'
// window.location.href = `${wxUrl}?appid=${appid}&redirect_uri=${encodeURIComponent(redirectUrl)}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`
// }
// } else {
// const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
// const { baseURL } = window.$fetchConfig.request
// let url = `${baseURL}/dj-scrm-wx-work-main/#/`
// window.location.href = `${url}?redirect_uri=${encodeURIComponent(redirectUrl)}&corpId=${storage_corpId.corpId}`
// }
// },
// navigation({ dispatch }) {
// let { sessionId, corpId } = getParams()
// const storage_corpId = util.getLocalStorage('dj_scrm_corpId')
// if (!corpId) corpId = storage_corpId && storage_corpId.corpId
// if (corpId && storage_corpId) {
// if (corpId != storage_corpId.corpId) {
// util.removeLocalStorage('dj_scrm_userInfo')
// util.clearSessionId()
// }
// }
// util.setLocalStorage('dj_scrm_corpId', { corpId })
// const storage_sessionId = util.getSessionId()
// if (sessionId || storage_sessionId) {
// state.showWindow = true
// util.setSessionId(sessionId || storage_sessionId)
// dispatch('registerHttp', sessionId || storage_sessionId)
// } else {
// util.showLoading()
// dispatch('registerHttp')
// dispatch('login')
// return
// }
// state.showWindow = true
// },
// registerHttp({}, sessionId = '') {
// window.$HTTP = new Http({ ...window.$fetchConfig, alert: Notify, headers: { token: sessionId } })
// }
} }
const getParams = name => { const getParams = name => {
let [url, paramsList] = window.location.href.split('?') const [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {} if (!paramsList) return name ? null : {}
let param = paramsList.split('&') const param = paramsList.split('&')
let obj = {} const obj = {}
param.map(e => { param.map(e => {
let [key, value] = e.split('=') const [key, value] = e.split('=')
obj[key] = value obj[key] = value
}) })
return name ? obj[name] : obj return name ? obj[name] : obj
......
const log = {}
/**
* @description 返回这个样式的颜色值
* @param {String} type 样式名称 [ primary | success | warning | danger | text ]
*/
function typeColor(type = 'default') {
let color = ''
switch (type) {
case 'default':
color = '#35495E'
break
case 'primary':
color = '#3488ff'
break
case 'success':
color = '#43B883'
break
case 'warning':
color = '#e6a23c'
break
case 'danger':
color = '#f56c6c'
break
default:
break
}
return color
}
/**
* @description 打印一个 [ title | text ] 样式的信息
* @param {String} title title text
* @param {String} info info text
* @param {String} type style
*/
log.capsule = function (title, info, type = 'primary') {
console.log(
`%c ${title} %c ${info} %c`,
'background:#35495E; padding: 1px; border-radius: 3px 0 0 3px; color: #fff;',
`background:${typeColor(type)}; padding: 1px; border-radius: 0 3px 3px 0; color: #fff;`,
'background:transparent'
)
}
/**
* @description 打印彩色文字
*/
log.colorful = function (textArr) {
console.log(`%c${textArr.map(t => t.text || '').join('%c')}`, ...textArr.map(t => `color: ${typeColor(t.type)};`))
}
/**
* @description 打印 default 样式的文字
*/
log.default = function (text) {
log.colorful([{ text }])
}
/**
* @description 打印 primary 样式的文字
*/
log.primary = function (text) {
log.colorful([{ text, type: 'primary' }])
}
/**
* @description 打印 success 样式的文字
*/
log.success = function (text) {
log.colorful([{ text, type: 'success' }])
}
/**
* @description 打印 warning 样式的文字
*/
log.warning = function (text) {
log.colorful([{ text, type: 'warning' }])
}
/**
* @description 打印 danger 样式的文字
*/
log.danger = function (text) {
log.colorful([{ text, type: 'danger' }])
}
export default log
...@@ -6,20 +6,20 @@ import { Toast, Dialog } from 'vant' ...@@ -6,20 +6,20 @@ import { Toast, Dialog } from 'vant'
* let time = new Date().format('yyyy-MM-dd hh:mm:ss') * let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/ */
Date.prototype.format = function (fmt) { Date.prototype.format = function (fmt) {
let o = { const o = {
'M+': this.getMonth() + 1, //月份 'M+': this.getMonth() + 1, // 月份
'd+': this.getDate(), //日 'd+': this.getDate(), // 日
'h+': this.getHours(), //小时 'h+': this.getHours(), // 小时
'm+': this.getMinutes(), //分 'm+': this.getMinutes(), // 分
's+': this.getSeconds(), //秒 's+': this.getSeconds(), // 秒
//季度 // 季度
'q+': Math.floor((this.getMonth() + 3) / 3), 'q+': Math.floor((this.getMonth() + 3) / 3),
S: this.getMilliseconds() //毫秒 S: this.getMilliseconds() // 毫秒
} }
if (/(y+)/.test(fmt)) { if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
} }
for (let k in o) { for (const k in o) {
if (new RegExp(`(${k})`).test(fmt)) { if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
} }
...@@ -32,14 +32,14 @@ const throttle = (fn, gapTime) => { ...@@ -32,14 +32,14 @@ const throttle = (fn, gapTime) => {
} }
let _lastTime = null let _lastTime = null
return function () { return function () {
let _nowTime = +new Date() const _nowTime = +new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) { if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments) fn.apply(this, arguments)
_lastTime = _nowTime _lastTime = _nowTime
} }
} }
} }
/**防止重复点击 */ /** 防止重复点击 */
const showLoading = (title = '加载中...') => { const showLoading = (title = '加载中...') => {
Toast({ Toast({
type: 'loading', type: 'loading',
...@@ -51,26 +51,26 @@ const showLoading = (title = '加载中...') => { ...@@ -51,26 +51,26 @@ const showLoading = (title = '加载中...') => {
const hideLoading = () => { const hideLoading = () => {
Toast.clear() Toast.clear()
} }
/**num:要转换的数值,fixed:精确几位小数 */ /** num:要转换的数值,fixed:精确几位小数 */
const decimal = (num, fixed) => { const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed) const pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow return Math.round(num * pow) / pow
} }
const showToast = (message = '', callBack) => { const showToast = (message = '', callBack) => {
hideLoading() hideLoading()
let params = { const params = {
message, message,
forbidClick: true, forbidClick: true,
duration: 1500 duration: 1500
} }
Toast(params) Toast(params)
if (callBack && typeof callBack == 'function') { if (callBack && typeof callBack === 'function') {
setTimeout(() => { setTimeout(() => {
callBack() callBack()
}, 1500) }, 1500)
} }
} }
/**触摸样式 */ /** 触摸样式 */
const touchstart = e => { const touchstart = e => {
e.target.classList.add('btn-on-leave') e.target.classList.add('btn-on-leave')
} }
...@@ -99,34 +99,34 @@ const dialog = (params = {}) => { ...@@ -99,34 +99,34 @@ const dialog = (params = {}) => {
if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336' if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336'
return Dialog.confirm(params) return Dialog.confirm(params)
} }
/**拨打电话 */ /** 拨打电话 */
const makePhoneCall = phoneNumber => { const makePhoneCall = phoneNumber => {
window.location.href = `tel://${phoneNumber}` window.location.href = `tel://${phoneNumber}`
} }
/**是否全面屏 */ /** 是否全面屏 */
const isFullSucreen = () => { const isFullSucreen = () => {
let result = false let result = false
const rate = window.screen.height / window.screen.width const rate = window.screen.height / window.screen.width
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值 const limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值
result = rate > limit result = rate > limit
return result return result
} }
const jumpChildrenPage = (to, params) => { const jumpChildrenPage = (to, params) => {
let { name } = window.vm._route const { name } = window.vm._route
window.vm.$router.push({ name: `${name}.${to}`, params }) window.vm.$router.push({ name: `${name}.${to}`, params })
} }
/**拷贝 */ /** 拷贝 */
const setClipboardData = data => { const setClipboardData = data => {
wx.setClipboardData({ wx.setClipboardData({
data, data,
success (res) { success(res) {
Toast('复制成功') Toast('复制成功')
} }
}) })
} }
/**接口请求时失败让用户刷新 */ /** 接口请求时失败让用户刷新 */
const refreshPage = (message = '系统异常') => { const refreshPage = (message = '系统异常') => {
return Dialog.alert({ return Dialog.alert({
message, message,
...@@ -136,12 +136,12 @@ const refreshPage = (message = '系统异常') => { ...@@ -136,12 +136,12 @@ const refreshPage = (message = '系统异常') => {
}) })
} }
const toTop = () => { const toTop = () => {
let bodySrcollTop = document.body.scrollTop const bodySrcollTop = document.body.scrollTop
if (bodySrcollTop !== 0) { if (bodySrcollTop !== 0) {
document.body.scrollTop = 0 document.body.scrollTop = 0
return return
} }
let docSrcollTop = document.documentElement.scrollTop const docSrcollTop = document.documentElement.scrollTop
if (docSrcollTop !== 0) { if (docSrcollTop !== 0) {
document.documentElement.scrollTop = 0 document.documentElement.scrollTop = 0
} }
...@@ -160,19 +160,18 @@ const watchPageBack = () => { ...@@ -160,19 +160,18 @@ const watchPageBack = () => {
} }
}) })
} }
/**分转元 */ /** 分转元 */
const centsToyuan = price => { const centsToyuan = price => {
return decimal(price / 100, 2).toFixed(2) return decimal(price / 100, 2).toFixed(2)
} }
/**设置cookie */ /** 设置cookie */
const setCookie = (c_name, value, expiredays = 365) => { const setCookie = (c_name, value, expiredays = 365) => {
let exdate = new Date() const exdate = new Date()
console.log(c_name, value) console.log(c_name, value)
exdate.setDate(exdate.getDate() + expiredays) exdate.setDate(exdate.getDate() + expiredays)
document.cookie = c_name + '=' + value + document.cookie = c_name + '=' + value + (expiredays == null ? '' : ';expires=' + exdate.toGMTString())
((expiredays == null) ? '' : ';expires=' + exdate.toGMTString())
} }
/**获取cookie */ /** 获取cookie */
const getCookie = c_name => { const getCookie = c_name => {
if (document.cookie.length > 0) { if (document.cookie.length > 0) {
let c_start = document.cookie.indexOf(c_name + '=') let c_start = document.cookie.indexOf(c_name + '=')
...@@ -185,6 +184,28 @@ const getCookie = c_name => { ...@@ -185,6 +184,28 @@ const getCookie = c_name => {
} }
return '' return ''
} }
/**
* This is just a simple version of deep copy
* Has a lot of edge cases bug
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
* @param {Object} source
* @returns {Object}
*/
const deepClone = source => {
if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'deepClone')
}
const targetObj = source.constructor === Array ? [] : {}
Object.keys(source).forEach(keys => {
if (source[keys] && typeof source[keys] === 'object') {
targetObj[keys] = deepClone(source[keys])
} else {
targetObj[keys] = source[keys]
}
})
return targetObj
}
const utils = { const utils = {
removeLocalStorage, removeLocalStorage,
setClipboardData, setClipboardData,
...@@ -211,7 +232,8 @@ const utils = { ...@@ -211,7 +232,8 @@ const utils = {
throttle, throttle,
decimal, decimal,
dialog, dialog,
toTop toTop,
deepClone
} }
Object.keys(utils).map(key => { Object.keys(utils).map(key => {
......
<template>
<div>
<template v-if="$route.meta.isTab">
<tab
:list="tabList"
@change="change"
:index="tabIndex"
sticky
></tab>
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<template v-for="(i,index) in list">
<div
:key="index"
:class="['item',`type-${tabIndex}`]"
>
<template v-if="tabIndex == 0">
<div class="top flex">
<div class="icon">
<div
class="status flex"
v-if="i.activityStatus == 2"
>
进行中
</div>
<img :src="i.activityImg">
</div>
<div class="info">
<div class="title text-hide">{{i.activityName}}</div>
<div class="time">时间:{{i.startTime}} ~ {{i.endTime}}</div>
<div class="price flex">
<template v-if="i.priceType == 1">
<div class="old">原价:¥{{i.price1}} </div>
<div class="now">¥{{i.price2}}</div>
</template>
<template v-else>
<div class="now">¥{{i.price1}} ~ {{i.price2}}</div>
</template>
</div>
</div>
</div>
<div class="bottom flex">
库存:{{i.goodsStock}}件
<div
class="btn text-center"
@click="showShareModel(i)"
>分享活动链接</div>
</div>
</template>
<template v-else>
<div class="icon">
<img :src="i.shareImgUrl">
</div>
<div class="info">
<div class="title text-hide">{{i.name}}</div>
<div class="time">直播时间:{{i.startTime}}</div>
<div class="zhubo flex">
主播:{{i.anchorName}}
<div
class="btn text-center"
@click="showShareModel(i)"
>分享直播间</div>
</div>
</div>
</template>
</div>
</template>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template>
</template>
</template>
<template v-else>
<router-view></router-view>
</template>
</div>
</template>
<script type='text/ecmascript-6'>
import { shareMixin, pageMixin } from '@/mixins'
import { activityApi, liveApi } from '@/api'
export default {
name: 'activity',
mixins: [shareMixin, pageMixin],
data () {
return {
tabList: ['秒杀活动']
}
},
methods: {
getList (pageNum) {
let { list, tabIndex } = this
let API = tabIndex == 0 ? activityApi : liveApi
let target = tabIndex == 0 ? 'getActivityList' : 'getLiveList'
API[target](pageNum).then(res => {
console.log(tabIndex == 0 ? '活动列表' : '直播列表', res)
if (tabIndex == 0) {
res.list.map(e => {
if (e.startTime) e.startTime = new Date(this.iosTimeFormat(e.startTime)).format('yyyy年M月d日')
if (e.endTime) e.endTime = new Date(this.iosTimeFormat(e.endTime)).format('yyyy年M月d日')
e.price1 = this.centsToyuan(e.price1 || 0)
e.price2 = this.centsToyuan(e.price2 || 0)
})
}
this.flag = true
this.list = list.concat(res.list)
this.total = res.total
this.hideLoading()
})
},
iosTimeFormat (time) {
return time.replace(/\-/g, '/')
}
}
}
</script>
<style scoped lang='scss'>
.list-box {
height: calc(100vh - 100px);
.item {
background: #ffffff;
border-radius: 4px;
margin-bottom: 10px;
box-sizing: border-box;
padding: 16px 10px 0;
display: flex;
position: relative;
font-size: 12px;
.info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
width: calc(100% - 100px);
.title {
color: #424242;
font-weight: 500;
font-size: 14px;
}
.time {
color: #666666;
}
}
}
.type-0 {
flex-direction: column;
height: 156px;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
.top {
align-items: flex-start;
.icon {
width: 84px;
height: 84px;
flex-shrink: 0;
margin-right: 16px;
position: relative;
.status {
position: absolute;
width: 42px;
height: 12px;
background: #ff653d;
border-radius: 6px;
color: #fff;
font-size: 8px;
top: 4px;
left: 4px;
box-sizing: border-box;
padding-left: 14px;
&::before {
content: '';
position: absolute;
top: 50%;
left: 4px;
width: 6px;
height: 6px;
border: 1px solid #fff;
transform: translateY(-50%);
border-radius: 100%;
}
&::after {
content: '';
position: absolute;
top: 50%;
left: 6px;
width: 4px;
height: 4px;
transform: translateY(-50%);
border-radius: 100%;
background-color: #fff;
}
}
}
.info {
height: 87px;
.price {
.old {
color: #666666;
text-decoration: line-through;
margin-right: 6px;
}
.now {
color: #3a3a3a;
font-size: 16px;
font-weight: 500;
}
}
}
}
.bottom {
margin-top: 20px;
color: #666666;
}
}
.type-1 {
height: 124px;
box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.08);
.icon {
width: 92px;
height: 91px;
flex-shrink: 0;
margin-right: 12px;
}
.info {
height: 94px;
.zhubo {
color: #939393;
}
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div>
paypage
<button id="test"
@click="getAuthCode"> getAuthCode </button>
</div>
</template>
<script>
// import { getProductType } from '@/api/alipayApi'
export default {
name: 'Alipay',
mounted() {
},
methods: {
getAuthCode() {
const appId = '2021003142659655'
// document.querySelector('#test').addEventListener('click', function () {
// console.log('111')
console.log('ap.getAuthCode', ap.getAuthCode)
ap.getAuthCode({
// appId: '${appId}',
appId: '2021003142659655',
// scopes: ['auth_user']
// 主动授权:auth_user,静默授权:auth_base。或者其它scope
scopes: ['auth_base']
}, function (res) {
console.log(res)
ap.alert(JSON.stringify(res))
})
// })
}
}
}
</script>
<style>
</style>
<template>
<div
class="layout"
v-if="flag"
>
<div class="box order">
<div class="title">订单信息</div>
<template v-for="(i,index) in orderObj">
<div
class="item"
:key="index"
>
<div class="label">{{i.label}}:</div>
<div class="value">
<template v-if="i.format">
{{ i.format(detail)}}
</template>
<template v-else>
{{detail[i.key] || ''}}
</template>
</div>
</div>
</template>
</div>
<div class="box">
<div class="title">订单商品</div>
<div class="subtitle">{{detail.merchantName}}</div>
<div class="goods-box">
<template v-for="(i,index) in detail.orderGoods">
<div
class="item flex"
:key="index"
>
<img
:src="i.goodsImage"
class="icon"
>
<div class="info flex">
<div class="name">{{i.goodsName}}</div>
<div class="price flex">
¥ {{i.retailPrice || 0}}
<div class="num">x{{i.goodsNumber || 1}}</div>
</div>
</div>
</div>
</template>
</div>
</div>
<div class="box order-price">
<div class="title">订单金额</div>
<div class="flex item">
<div class="label">商品总价:</div>
<div class="value">¥{{price}}</div>
</div>
<div class="flex item">
<div class="label">运费:</div>
<div class="value">¥{{detail.expressFee}}</div>
</div>
<div class="total flex item">
<div class="label">订单金额:</div>
<div class="value">
<span class="unit">¥</span>{{total}}
</div>
</div>
</div>
<div
class="btn text-center"
@click="submit"
v-if="!hideBtn"
>确认核销</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { shopmallApi } from '@/api'
export default {
name: '',
data () {
return {
flag: false,
hideBtn: false,
detail: {},
total: 0,
price: 0,
orderObj: [
{
label: '客户姓名',
key: 'customerName'
},
{
label: '下单日期',
format (item) {
return new Date(item.createdDate).format('yyyy.MM.dd hh:mm')
}
},
{
label: '订单编号',
key: 'orderCode'
},
{
label: '收货地址',
key: 'shipAddress'
},
{
label: '订单状态',
format (item) {
return {
1: '待付款',
2: '已支付',
3: '已关闭',
4: '已发货',
5: '已收货',
6: '待发货',
7: '待安装',
8: '已安装',
9: '售后中',
10: '售后完成'
}[item.orderStatus]
}
}
]
}
},
activated () {
let { verficationCode, orderCode } = this.getParams()
this.showLoading()
if (orderCode) this.getGoodsDetail(orderCode)
else shopmallApi
.getGoodsVerficationDetail(verficationCode)
.then(res => {
this.setData(res)
})
},
mounted () {
},
deactivated () {
Object.assign(this.$data, this.$options.data.call(this))
},
methods: {
setData (res) {
res.orderGoods.map(e => (this.price += e.retailPrice))
this.detail = res
this.flag = true
this.total = this.price + res.expressFee
this.hideLoading()
},
getGoodsDetail (orderCode) {
shopmallApi.getGoodsDetail(orderCode).then(res => {
this.setData(res)
this.hideBtn = true
})
},
submit () {
let { verficationCode } = this.getParams()
this.showLoading()
shopmallApi
.verficationGoods(verficationCode)
.then(res => {
this.hideLoading()
if (res) {
this.$route.params.isGoods = true
this.showToast('已核销', () => {
this.$router.back()
})
}
})
}
}
}
</script>
<style scoped lang='scss'>
.layout {
padding: 0 16px 60px;
.box {
background: linear-gradient(180deg, #ffffff 0%, #ffffff 100%);
border-radius: 4px;
padding: 12px;
margin-top: 10px;
font-size: 12px;
.title {
font-size: 16px;
font-weight: 500;
color: #282829;
margin-bottom: 12px;
}
.subtitle {
color: #2d2d2e;
margin-bottom: 16px;
}
.goods-box {
.item {
margin-bottom: 20px;
.icon {
width: 80px;
height: 80px;
margin-right: 10px;
}
.info {
width: calc(100% - 90px);
height: 80px;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
.name {
font-size: 15px;
font-weight: 500;
color: #333333;
}
.price {
font-size: 14px;
color: #3975c6;
width: 100%;
.num {
margin-left: auto;
color: #656566;
}
}
}
&:last-of-type {
margin-bottom: 0;
}
}
}
}
.order {
.item {
display: flex;
color: #282829;
line-height: 24px;
.label {
width: 70px;
flex-shrink: 0;
}
.value {
width: 246px;
color: #656566;
}
}
}
.order-price {
.item {
justify-content: space-between;
font-size: 12px;
color: #656566;
line-height: 30px;
.value {
font-weight: 600;
font-size: 14px;
color: #3975c6;
.unit {
font-size: 12px;
}
}
}
.total {
margin-bottom: 2px;
border-top: 1px solid #e3e3e6;
}
}
.btn {
position: fixed;
width: 343px;
left: 50%;
bottom: 16px;
transform: translateX(-50%);
height: 42px;
font-size: 14px;
border-radius: 21px;
box-sizing: border-box;
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div class="index">
<template v-if="$route.meta.isTab">
<tab
:list="tabList"
@change="change"
:index="tabIndex"
:updata="updata"
sticky
></tab>
<template v-if="tabIndex==1 && showTips">
<div class="tips flex">
<div class="label">温馨提示:</div>
<div class="text">
<van-notice-bar
scrollable
speed="30"
text="多次发送同张优惠券给客户,客户可领取多张,请注意控制成本"
/>
</div>
<div
class="close flex"
@click="closeTips"
>
<div class="sprite-icon icon-close"></div>
</div>
</div>
</template>
<template v-if="flag">
<template v-if="list.length">
<scroll-view
:class="['list-box',{'tips-type':showTips && tabIndex == 1}]"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<template v-for="(i,index) in list">
<div
:key="index"
class="item"
>
<div :class="['sprite-icon', 'text-center',tabIndex == 0 ?'icon-coupon':'icon-discount', {'clear-padding':i.discountType == 3}]">
<template v-if="tabIndex == 0 ">
{{i.couponTypeName}}
</template>
<template v-else>
<template v-if="i.discountType == 3">
<span>¥</span>{{i.denomination}}
</template>
<template v-else>
{{discountType[i.discountType]}}
</template>
</template>
</div>
<div class="info">
<div class="top">
<div class="title">{{i.couponName}}</div>
<div class="num">剩余:{{i.remainAmount || i.residueAmount || 0}}张</div>
<div
:class="['btn', 'y-center', 'text-center', {'disabled-btn':tabIndex == 0 ?i.remainAmount<1:i.residueAmount<1}]"
@click="showShareModel(i)"
>发送</div>
</div>
<div class="bottom">
<template v-if="tabIndex == 0 ">
<div>永久有效</div>
<div class="right">适用于新车购买用户</div>
</template>
<template v-else>
<div class="right">活动商品,满足条件可使用</div>
</template>
</div>
</div>
</div>
</template>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template>
</template>
</template>
<template v-else>
<router-view></router-view>
</template>
<template v-if="tabIndex == 1">
<van-dialog
v-model="showCouponModal"
confirmButtonText="我知道了"
confirmButtonColor="#3975C6"
@confirm="closeCouponModal"
>
<div class="modal-content flex">
<div class="sprite-icon icon-coupon-tips"></div>
<div class="modal-content-title">温馨提示</div>
<div class="modal-content-text">多次发送同张优惠券给客户,客户可领取多张,请注意控制成本</div>
<div class="modal-content-radio flex">
<van-checkbox
v-model="modalChecked"
checked-color="#3975C6"
shape="square"
icon-size="16px"
></van-checkbox>
以后不再提示
</div>
</div>
</van-dialog>
</template>
</div>
</template>
<script type='text/ecmascript-6'>
import { shareMixin, pageMixin, discountTypeMixin } from '@/mixins'
import { couponApi, boutiquecouponApi } from '@/api'
export default {
name: 'coupon',
mixins: [shareMixin, pageMixin, discountTypeMixin],
data () {
return {
tabList: ['新车精品礼券', '商城优惠券'],
showTips: true,
showCouponModal: false,
modalChecked: false,
corpId: ''
}
},
mounted () {
let { corpId } = this.getQuery()
if (!corpId) corpId = this.getLocalStorage('dj_scrm_corpId').corpId
const tomorrow = this.getLocalStorage(`tips_${corpId}`)
const couponModal = this.getLocalStorage(`modal_${corpId}`)
this.corpId = corpId
console.log(couponModal, tomorrow, corpId)
if (tomorrow) this.showTips = new Date().getTime() >= tomorrow
this.showCouponModal = !couponModal
},
methods: {
getList (pageNum) {
let { list, tabIndex } = this
let API = tabIndex == 0 ? boutiquecouponApi : couponApi
let target = tabIndex == 0 ? 'getBoutiqueCouponList' : 'getMerchantCouponList'
API[target]({ pageNum }).then(res => {
this.hideLoading()
console.log(tabIndex == 0 ? '精品礼券' : '商城礼券', res)
this.flag = true
this.list = list.concat(res.list)
this.total = res.total
})
},
closeTips () {
let { corpId } = this
this.showTips = false
let tomorrow = new Date(`${new Date(new Date().setDate(new Date().getDate() + 1)).format('yyyy/MM/dd')} 00:00:00`).getTime()
this.setLocalStorage(`tips_${corpId}`, tomorrow)
},
closeCouponModal () {
let { modalChecked, corpId } = this
if (!modalChecked) return
this.setLocalStorage(`modal_${corpId}`, true)
}
}
}
</script>
<style scoped lang='scss'>
.tips {
position: sticky;
top: 50px;
height: 32px;
background: #e5effd;
z-index: 2;
font-size: 12px;
color: #333333;
padding-left: 16px;
&::before {
content: '';
width: 1px;
height: 14px;
background-color: #3975c6;
margin-right: 7px;
}
.label {
flex-shrink: 0;
}
.close {
margin-left: auto;
width: 32px;
height: 100%;
justify-content: flex-end;
padding-right: 16px;
}
.text {
width: calc(100% - 100px);
.van-notice-bar {
padding: 0;
background: #e5effd;
color: #333333;
font-size: 12px;
height: 100%;
line-height: normal;
}
}
}
.list-box {
height: calc(100vh - 100px);
.item {
margin-bottom: 10px;
height: 100px;
background: #ffffff;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
border-radius: 4px;
padding: 0 10px;
box-sizing: border-box;
display: flex;
align-items: center;
.sprite-icon {
font-size: 18px;
line-height: 25px;
font-weight: 600;
color: #ffffff;
box-sizing: border-box;
padding: 0 14px;
flex-shrink: 0;
text-align: center;
span {
font-size: 10px;
}
}
.clear-padding {
padding: 0;
}
.info {
margin-left: 8px;
flex: 1;
.top {
display: flex;
flex-direction: column;
justify-content: space-between;
color: #2d2d2e;
height: 58px;
padding-top: 10px;
position: relative;
// border-bottom: 1px dotted #b9babb;
&::after {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 1px;
background-image: linear-gradient(to right, transparent 0, transparent 50%, #b9babb 50%, #b9babb 100%);
background-size: 4px 1px;
background-repeat: repeat-x;
content: '';
}
.title {
font-weight: 600;
font-size: 14px;
width: 75%;
}
.num {
color: #b9babb;
margin-bottom: 4px;
font-size: 12px;
}
.btn {
width: 60px;
box-shadow: 0px 2px 6px 2px rgba(88, 80, 255, 0.11);
right: 0;
font-size: 10px;
box-sizing: border-box;
}
.disabled-btn {
background: #999 !important;
}
}
.bottom {
display: flex;
align-items: center;
height: 31px;
font-size: 10px;
color: #b9babb;
.right {
margin-left: auto;
}
}
}
}
}
.tips-type {
height: calc(100vh - 132px);
}
.modal-content {
flex-direction: column;
padding: 24px 24px 9px;
color: rgba(10, 17, 26, 0.5);
font-size: 15px;
&-title {
font-size: 17px;
font-weight: 500;
color: #000000;
margin: 19px 0 8px;
}
&-text {
text-align: center;
}
&-radio {
margin-top: 8px;
font-size: 14px;
color: #666666;
height: 16px;
justify-content: center;
.van-checkbox {
margin-right: 4px;
}
}
}
</style>
\ No newline at end of file \ No newline at end of file
<template>
<div
class="layout"
v-if="flag"
>
<div class="title">客户信息</div>
<div class="box">
<template v-for="(i,index) in customerObj">
<div
:key="index"
class="item flex"
>
<div class="label">{{i.label}}</div>
<div class="value">
<template v-if="i.format">
{{ i.format(detail)}}
</template>
<template v-else>
{{detail[i.key] || ''}}
</template>
</div>
</div>
</template>
</div>
<div class="title">{{detail.discountType == 7?'服务信息':'优惠券信息'}}</div>
<div class="box">
<template v-for="(i,index) in infoObj">
<div
:key="index"
class="item flex"
v-if="detail[i.key]"
>
<div class="label">
{{i.label}}
<template v-if="i.tipsLabel">
<div class="item-tips">{{i.tipsLabel}}</div>
</template>
</div>
<div class="value">
<template v-if="i.format">
<div v-html="i.format(detail)"></div>
</template>
<template v-else>
{{detail[i.key] || ''}}
<template v-if="i.tipsValue">
<div
class="item-tips"
v-html="i.tipsValue(detail)"
></div>
</template>
</template>
</div>
</div>
</template>
<template v-if="detail.discountType == 7">
<div class="item flex">
<div class="label">使用限制</div>
<div class="value flex">
<div class="value-btn text-center">
已经核销{{detail.usedAmount}}次
</div>
<div class="use-type">
<template v-if="detail.useType == 0">不限次数</template>
<template v-else-if="detail.useType == 1">
{{detail.effectiveType > 2 ? '' : '有效期内'}}可用{{detail.useAllAmount}}次
</template>
<template v-else>
每隔{{detail.useLimitDays}}天
|
可用{{detail.useAmount}}次
</template>
</div>
</div>
</div>
<template v-if="detail.directionalGiftName">
<div class="item flex">
<div class="label">
所属定向礼包
<div class="item-tips">领取条件</div>
</div>
<div class="value">
{{detail.directionalGiftName}}
<div class="item-tips">
{{detail.directionalGiftReceiveWay == 1?'手机号':'车架号后6位'}}:{{detail.directionalGiftReceiveCondition}}
</div>
</div>
</div>
</template>
</template>
<div v-if="detail.packageId" class="item flex">
<div class="label">所属套餐</div>
<div class="value">
<div class="value">{{ detail.packageName }}</div>
<div v-if="detail.receiveWay == 6" class="sprite-icon icon-detail-group"></div>
</div>
</div>
</div>
<div
v-if="!hideBtn"
class="btn text-center"
@click="submit"
>确认核销</div>
</div>
</template>
<script type='text/ecmascript-6'>
import { discountTypeMixin } from '@/mixins'
import { couponApi } from '@/api'
const couponObj = [
{
label: '优惠券名称',
key: 'couponName'
},
{
label: '券编号',
key: 'verificationCode'
},
{
label: '类型',
key: 'discountType',
format (item) {
return `${window.$discountType[item.discountType]}券`
}
},
{
label: '所属定向礼包',
key: 'directionalGiftName',
tipsLabel: '领取条件',
tipsValue (item) {
return `${item.directionalGiftReceiveWay == 1 ? '手机号' : '车架号后6位'}:${item.directionalGiftReceiveCondition}`
}
},
{
label: '发放人',
key: 'issueName'
},
{
label: '发放时间',
key: 'issueDate',
format (item) {
return item.issueDate ? new Date(item.issueDate).format('yyyy年MM月dd日') : ''
}
}
]
const vipObj = [
{
label: '所属套餐',
key: 'packageName'
},
{
label: '服务名称',
key: 'couponName'
},
{
label: '类型',
key: 'discountType',
format () {
return '服务券'
}
},
{
label: '有效期',
key: 'effectiveType',
format (item) {
let { effectiveType } = item
let str = ''
if (effectiveType == 1) str = `${item.effectiveDays}天`
else if (effectiveType == 1) str = `${new Date(item.effectiveStartTime).format('yyyy/MM/dd')} ~ ${new Date(item.effectiveEndTime).format('yyyy/MM/dd')}`
else str = '无有效期'
return str
}
},
]
export default {
name: '',
mixins: [discountTypeMixin],
data () {
return {
detail: {},
customerObj: [
{
label: '客户姓名',
key: 'userName'
},
{
label: '客户手机号',
key: 'phone'
},
{
label: '领取时间',
key: 'receiveTime',
format (item) {
return item.receiveTime ? new Date(item.receiveTime).format('yyyy年MM月dd日') : ''
}
}
],
infoObj: [],
verficationCode: '',
flag: false,
hideBtn: false
}
},
activated () {
let { verficationCode, hideBtn } = this.getParams()
this.showLoading()
this.hideBtn = hideBtn
couponApi.scan({ verficationCode }).then(res => {
this.hideLoading()
this.detail = res || {}
this.infoObj = res.discountType == 7 ? vipObj : couponObj
this.verficationCode = verficationCode
this.flag = true
})
},
mounted () {
},
deactivated(){
Object.assign(this.$data, this.$options.data.call(this))
},
methods: {
submit () {
let { detail: { discountType } } = this
let { verficationCode } = this
this.showLoading()
couponApi.verificationCode({ verficationCode }).then(res => {
this.hideLoading()
if (res) {
this.$route.params.discountType = discountType
this.showToast('已核销', () => {
this.$router.back()
})
}
})
}
}
}
</script>
<style scoped lang='scss'>
.layout {
padding: 0 16px 60px;
.title {
padding: 16px 0 10px;
font-weight: 500;
font-size: 16px;
color: #393939;
}
.box {
background: #ffffff;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
border-radius: 4px;
.item {
height: 66px;
font-size: 14px;
color: #3a3a3a;
padding: 0 16px;
border-bottom: 1px solid rgba(195, 195, 195, 0.3);
&-tips {
color: #666666;
margin-top: 10px;
font-size: 12px;
}
.label {
.item-tips {
margin-left: 8px;
}
}
&:last-of-type {
border-bottom: none;
}
.value {
margin-left: auto;
color: #333333;
text-align: right;
&-btn {
font-size: 12px;
color: #3975c6;
// padding: 0 6px;
height: 24px;
// background: rgba(57, 117, 198, 0.15);
// border-radius: 4px;
margin-right: 4px;
}
.item-tips {
color: #333333;
}
}
}
}
.btn {
position: fixed;
width: 343px;
left: 50%;
bottom: 16px;
transform: translateX(-50%);
height: 42px;
font-size: 14px;
border-radius: 21px;
box-sizing: border-box;
}
}
.icon-detail-group {
width: 64px;
height: 24px;
background-image: url(../../assets/images/icon-detail-group.png);
background-size: 64px 24px;
margin-top: 4px;
}
</style>
<template>
<div class="gift-layout">
<template v-if="flag">
<div class="box">
<div class="item">
<div class="label">礼包名称</div>
<div class="value">
<van-field
v-model="obj.name"
input-align="right"
maxlength="15"
placeholder="请输入礼包名称"
@input="input"
/>
</div>
</div>
<div class="item">
<div class="label">
备注名称
<span>(仅内部可见)</span>
</div>
<div class="value">
<van-field
v-model="obj.remarkName"
input-align="right"
maxlength="30"
placeholder="可按车主姓名+手机号形式备注"
@input="input"
/>
</div>
</div>
</div>
<div class="box">
<div class="item">
<div class="label">礼包明细</div>
<div class="value">预估成本:<span>¥{{centsToyuan(total)}}</span></div>
</div>
<template v-if="obj.couponList && obj.couponList.length">
<div class="detail-box">
<template v-for="(i,index) in obj.couponListView">
<div
class="detail"
:key="index"
>
<!-- status 优惠券状态(1:未生效,2:生效中,3:已失效) -->
<!-- 优惠券类型 1:满减券,2:折扣券,3:代金券,4:兑换券 5:购车代金券 6:商品折扣券,7:门店服务 -->
<span class="detail-title text-center">{{discountEnum[i.discountType]}}</span>
<template v-for="(e,ind) in i.list">
<div
:class="['detail-item',{'coupon-disabled':e.status != 2 && obj.receivedFlag != 2}]"
:key="ind"
>
<div class="name flex">
{{e.couponName}}
<template v-if="e.status != 2 && obj.receivedFlag != 2">
<div class="name-tips text-center">{{{1:'未生效',3:'已失效'}[e.status]}}</div>
</template>
</div>
<div class="num flex">
数量:x{{e.couponAmount}}
<div class="price">¥{{centsToyuan(e.couponAnticipatedCost * e.couponAmount)}}</div>
</div>
<div class="del sprite-icon icon-gift-del" @click="delCoupon(e)"></div>
</div>
</template>
</div>
</template>
</div>
</template>
<div :class="['add-box text-center',{'add-line':obj.couponList.length}]">
<div
class="add-btn text-center"
@click="showGiftModal"
>
<div class="sprite-icon icon-gift-add"></div>
</div>
</div>
</div>
<div class="box readonly-box radio-box">
<div class="title">领取条件</div>
<template v-for="(i,index) in receiveWayObj">
<div
class="radio-item"
:key="index"
>
<div
class="radio-name flex"
@click="changeRadio(index)"
>
<div :class="['radio',{'radio-active':obj.receiveWay == i.value}]"></div>
{{i.name}}
</div>
<template v-if="obj.receiveWay == i.value">
<div class="radio-input">
<van-field
v-model="obj[i.key]"
:type="i.type || 'text'"
:maxlength="i.maxlength"
:placeholder="i.placeholder"
@input="input(i,$event)"
/>
</div>
</template>
</div>
</template>
</div>
<div class="box readonly-box textarea">
<div class="title">赠送原因</div>
<div class="textarea-box">
<van-field
v-model="obj.giveReason"
type="textarea"
placeholder="请说明赠送礼包的原因(非必填)"
maxlength="50"
@input="input"
/>
</div>
</div>
<div
:class="['btn text-center x-center create',{'disabled-btn':disabled}]"
@click="submit"
>{{id?'确定':'创建'}}</div>
</template>
<gift-modal
ref="GiftModal"
:selectedList="obj.couponList"
@confirm="couponConfirm"
/>
</div>
</template>
<script type='text/ecmascript-6'>
import GiftModal from './GiftModal.vue'
import { giftApi, wxConfig} from '@/api'
import { discountTypeMixin } from '@/mixins'
import { setApproveParam } from '@/mixins/giftMixin'
export default {
name: '',
components: { GiftModal },
mixins: [discountTypeMixin],
data () {
return {
flag: false,
disabled: true,
obj: {
receiveWay: 1,
couponList: []
},
receiveWayObj: [
{ name: '指定手机号', type: 'tel', placeholder: '客户需输入指定的手机号,才能成功领取礼包', maxlength: 11, key: 'phone', value: 1 },
{ name: '指定车架号后6位', placeholder: '客户需输入指定的车架号,才能成功领取礼包', maxlength: 6, key: 'vin', value: 2 },
],
total: 0,
id: '',
test: ''
}
},
mounted () {
let { id } = this.getQuery()
if (id) {
this.getDetail(id)
this.id = id
}
else this.flag = true
wxConfig.init(['thirdPartyOpenPage','onHistoryBack'])
},
methods: {
input (i, e) {
if (i && i.key == 'vin') this.obj[i.key] = e.replace(/[^0-9a-zA-Z]/g, '')
this.checkData()
},
setCouponData (res) {
let total = 0
let discountTypeList = Array.from(new Set([...res.couponList.map(e => e.discountType)]))
res.couponList.map(e => {
if (e.status == 2) total += Number(e.couponAnticipatedCost) * e.couponAmount
})
res.couponListView = discountTypeList.map(i => {
let list = []
res.couponList.map(e => {
if (i == e.discountType) list.push(e)
})
return {
discountType: i,
list
}
})
this.total = total
return res
},
getDetail (id) {
giftApi.getGiftDetail(id).then(res => {
this.hideLoading()
res = this.setCouponData(res)
this.flag = true
if (res.receiveWay == 1) res.phone = res.receiveDetails
else res.vin = res.receiveDetails
this.obj = res
this.checkData()
})
},
changeRadio (index) {
this.obj.receiveWay = index == 0 ? 1 : 2
this.checkData()
},
showGiftModal () {
this.$refs.GiftModal.toggle()
},
couponConfirm ({ chooseItems }) {
this.obj.couponList = JSON.parse(JSON.stringify(chooseItems))
this.obj = this.setCouponData(this.obj)
this.checkData()
},
checkData () {
let { obj } = this
let target = ['name', 'remarkName', 'couponList', 'phone', 'vin']
try {
target.map(key => {
if (key == 'phone' || key == 'vin') {
if (obj.receiveWay == 1) {
if (!obj.phone) throw key
} else {
if (!obj.vin) throw key
}
} else {
if (!obj[key]) throw key
if (Array.isArray(obj[key])) {
if (!obj[key].length) throw key
}
}
})
} catch (error) {
this.disabled = true
return
}
this.disabled = false
},
delCoupon (e) {
let { obj: { couponList } } = this
let index = null
couponList.map((i, ind) => {
if (i.discountType == e.discountType && i.couponId == e.couponId) index = ind
})
couponList.splice(index, 1)
this.obj.couponList = couponList
this.obj = this.setCouponData(this.obj)
this.checkData()
},
submit () {
const phoneRex = /^[1]([3-9])[0-9]{9}$/
let { obj, disabled, id } = this
if (disabled) return
if (obj.receiveWay == 1) {
if (!phoneRex.test(obj.phone)) {
this.showToast('请输入正确的手机号')
return
}
} else {
if (obj.vin.length < 6) {
this.showToast('请输入车架号的后6位')
return
}
}
try {
obj.couponList.map(e => {
if (e.status != 2) throw false
})
} catch (error) {
this.showToast('礼包有失效券')
return
}
let couponCreateRequests = []
obj.couponList.map(e => {
couponCreateRequests.push({
couponId: e.couponId,
couponAmount: e.couponAmount,
couponAnticipatedCost: e.couponAnticipatedCost
})
})
let params = {
name: obj.name,
remarkName: obj.remarkName,
receiveWay: obj.receiveWay,
giveReason: obj.giveReason,
couponCreateRequests,
receiveDetails: obj.receiveWay == 1 ? obj.phone : obj.vin
}
if (id){
params.id = id
}
params.requestSource = 2
this.showLoading('提交中...')
giftApi.createOrupdataGift(params).then(res => {
this.hideLoading()
if(res.approveFlag ===2){
wxConfig.thirdPartyOpenPage(setApproveParam(res))
.then((resp) => {
console.log(resp,'已发起审批')
setTimeout(()=>{
this.$router.replace({ name: 'gift.detail', query: {id:res.directionalGiftId,approveStatus:999}})
},500)
})
}else{
this.$route.params.giftToast = `${id ? '修改' : '创建'}成功`
this.$router.back()
}
})
}
}
}
</script>
<style scoped lang='scss'>
@import '@/assets/css/gift-detail.scss';
.item {
.van-field {
padding: 0;
}
}
.add-line {
border-top: 1px solid rgba(195, 195, 195, 0.3);
}
</style>
\ No newline at end of file \ No newline at end of file
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="layout-content"> <div class="layout-content">
<!-- <div>layout</div> -->
<!-- <NavBar :meta="app.pageMeta"> --> <!-- <NavBar :meta="app.pageMeta"> -->
<!-- <keep-alive v-if="$route.meta.keepAlive"> <keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view> <router-view></router-view>
</keep-alive> </keep-alive>
<router-view v-else></router-view> --> <router-view v-else></router-view>
<!--缓存想要缓存的页面,实现后退不刷新--> <!--缓存想要缓存的页面,实现后退不刷新-->
<!--加上v-if的判断,可以自定义想要缓存的组件,自定义在router里面--> <!--加上v-if的判断,可以自定义想要缓存的组件,自定义在router里面-->
<div class="container"> <!-- <div class="container">
<transition <transition :name="app.transitionName"
:name="app.transitionName" mode="out-in">
mode="out-in"
>
<keep-alive :include="app.keepAlives"> <keep-alive :include="app.keepAlives">
<router-view /> <router-view />
</keep-alive> </keep-alive>
</transition> </transition>
</div> </div> -->
<!-- </NavBar> --> <!-- </NavBar> -->
</div> </div>
</div> </div>
...@@ -25,10 +24,23 @@ ...@@ -25,10 +24,23 @@
<script> <script>
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { getProductType, getBankListApi } from '@/api/alipayApi'
export default { export default {
name: 'AppLayout', name: 'AppLayout',
computed: { computed: {
...mapGetters(['app']) ...mapGetters(['app'])
},
mounted() {
// getBankListApi({}).then((result) => {
// console.log(result)
// }).catch((err) => {
// console.log(err)
// })
// getProductType({}).then((result) => {
// console.log(result)
// }).catch((err) => {
// console.log(err)
// })
} }
} }
</script> </script>
......
<template>
<div>
<template v-if="$route.meta.isIndex">
<tab
:list="tabList"
@change="change"
sticky
:index="tabIndex"
:updata="updata"
></tab>
<template v-if="tabIndex == 0">
<div class="bg-box">
<div class="bg">
<div class="item item-1"></div>
<div class="item item-2"></div>
<div class="item item-3"></div>
<div class="item item-4"></div>
</div>
<div
class="btn x-center text-center"
@click="showShareModel()"
>一键分享</div>
</div>
</template>
<template v-else>
<template v-if="flag">
<template v-if="list.length">
<scroll-view
class="list-box"
@ReachBottom="onReachBottom"
ref="scrollView"
>
<div :class="[`type-${tabIndex - 1}`]">
<template v-for="(i, index) in list">
<div
:key="index"
class="item"
>
<template v-if="tabIndex == 1">
<div class="sprite-icon icon-vip"></div>
<div class="info">
<div>
<div class="title text-hide">{{ i.packageName }}</div>
<div class="decoration">价值{{ i.totalMerchantPrice }}元的{{ i.list.length || 0 }}项权益</div>
</div>
<div
class="btn text-center"
@click="showVipDialog(i)"
>查看套餐</div>
</div>
<div
class="btn text-center y-center"
@click="showShareModel(i)"
>分享给客户</div>
</template>
<template v-else>
<div
@click="showShareModel(i)"
class="goods"
>
<div class="icon">
<img :src="i.goodsImage || ''" />
</div>
<div class="info">
<div class="name text-two-line">{{i.goodsName}}</div>
<template v-if="i.price != null || i.activityPrice != null">
<div class="price flex">
<template v-if="i.activityPrice">
<div class="activity">秒杀价</div>
</template>
<div class="unit">¥</div>
<div class="num">
<template v-if="i.activityPrice != null">{{i.activityPrice.toFixed(2)}}</template>
<template v-else>{{i.price.toFixed(2)}}</template>
</div>
</div>
</template>
<div class="stock">库存:{{i.goodsStock}}</div>
<div class="sprite-icon icon-goods-share"></div>
</div>
</div>
</template>
</div>
</template>
</div>
</scroll-view>
</template>
<template v-else>
<van-empty description="暂无内容" />
</template>
</template>
</template>
<vip-dialog
v-model="showVip"
@cancel="showVip = false"
:id="equity_id"
></vip-dialog>
</template>
<template v-else>
<router-view></router-view>
</template>
</div>
</template>
<script type="text/ecmascript-6">
import { shareMixin, pageMixin } from '@/mixins'
import { shopmallApi, equityApi } from '@/api'
const tabList = ['我的店铺', '会员套餐', '门店商品']
export default {
name: 'merchant',
mixins: [shareMixin, pageMixin],
data () {
return {
showVip: false,
equity_id: null,
tabList
}
},
methods: {
getList (pageNum) {
let { list, tabIndex } = this
if (tabIndex == 0) {
this.flag = true
this.hideLoading()
return
}
let API = tabIndex == 1 ? equityApi : shopmallApi
let target = tabIndex == 1 ? 'getEquityList' : 'getGoodsList'
API[target](pageNum).then(res => {
this.flag = true
this.list = list.concat(res.list)
this.total = res.total
this.hideLoading()
})
},
showVipDialog (i) {
this.showVip = true
this.equity_id = i.id
}
}
}
</script>
<style scoped lang="scss">
.list-box {
height: calc(100vh - 100px);
.item {
background: #ffffff;
border-radius: 4px;
overflow: hidden;
margin-bottom: 10px;
box-sizing: border-box;
font-size: 12px;
position: relative;
}
.type-0 {
.item {
height: 100px;
display: flex;
box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.08);
padding: 10px;
.sprite-icon {
border-radius: 4px;
overflow: hidden;
margin-right: 11px;
}
.info {
display: flex;
justify-content: space-between;
flex-direction: column;
max-width: 70%;
.title {
font-weight: 500;
font-size: 14px;
color: #282829;
}
.decoration {
color: #b9babb;
width: 160px;
}
.btn {
color: #b1b1b3;
margin-left: 0;
margin-right: auto;
font-size: 12px;
padding: 0 10px;
height: 24px;
border-radius: 39px;
border: 1px solid #b3b3b3;
box-sizing: border-box;
background-color: #fff;
}
}
.btn {
right: 10px;
z-index: 2;
}
}
}
.type-1 {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.item {
width: 164px;
height: 229px;
box-shadow: 0px 4px 8px 0px rgba(224, 224, 224, 0.5);
.icon {
height: 120px;
}
.info {
height: calc(100% - 120px);
box-sizing: border-box;
padding: 12px 8px 10px;
display: flex;
justify-content: space-between;
flex-direction: column;
position: relative;
.name {
color: #3a3a3a;
line-height: 20px;
height: 40px;
}
.stock {
font-size: 12px;
color: #a9a9a9;
}
.price {
color: var(--themeColor);
font-size: 0;
align-items: baseline;
letter-spacing: -0.5px;
.activity {
font-size: 8px;
}
.unit {
font-size: 10px;
}
.num {
font-size: 16px;
font-weight: 500;
// font-family:;
}
}
.icon-goods-share {
position: absolute;
bottom: 10px;
right: 12px;
}
}
}
}
}
.bg-box {
width: 347px;
height: 1354px;
margin: 16px 14px 0;
padding-bottom: 70px;
.bg {
width: 100%;
height: 100%;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-bg.png');
background-size: cover;
box-sizing: border-box;
padding-top: 28px;
.item {
margin-bottom: 12px;
background-size: cover;
}
.item-1 {
width: 298px;
height: 312px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-1.png');
margin-left: 19px;
}
.item-2 {
width: 298px;
height: 268px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-2.png');
margin-left: 20px;
}
.item-3 {
width: 296px;
height: 345px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-3.png');
margin-left: 21px;
}
.item-4 {
width: 287px;
height: 358px;
background-image: url('https://img01.glsx.com.cn/weapp/resource/scrm-mobile/activity/merchant-4.png');
margin-left: 25px;
}
}
.btn {
position: fixed !important;
width: 343px;
height: 42px;
background: #3875c5;
border-radius: 22px;
left: 50%;
bottom: 10px;
font-size: 16px;
}
}
</style>
...@@ -4,53 +4,55 @@ const defaultSettings = require('./src/config/conf.js') ...@@ -4,53 +4,55 @@ const defaultSettings = require('./src/config/conf.js')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const resolve = dir => path.join(__dirname, dir) const resolve = dir => path.join(__dirname, dir)
// page title // page title
const name = defaultSettings.title || 'vue mobile template' const name = defaultSettings.title || 'vue mobile template'
// 生产环境,测试和正式 // 生产环境,测试和正式
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV) const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
// externals // externals
// const externals = { // const externals = {
// vue: 'Vue', // vue: 'Vue',
// 'vue-router': 'VueRouter', // 'vue-router': 'VueRouter',
// vuex: 'Vuex', // vuex: 'Vuex',
// vant: 'vant', // vant: 'vant',
// axios: 'axios' // axios: 'axios'
// } // }
// CDN外链,会插入到index.html中 // CDN外链,会插入到index.html中
// const cdn = { // const cdn = {
// // 开发环境 // // 开发环境
// dev: { // dev: {
// css: [], // css: [],
// js: [] // js: []
// }, // },
// // 生产环境 // // 生产环境
// build: { // build: {
// css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'], // css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'],
// js: [ // js: [
// 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js', // 'https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js',
// 'https://cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js', // 'https://cdn.jsdelivr.net/npm/vue-router@3.1.5/dist/vue-router.min.js',
// 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js', // 'https://cdn.jsdelivr.net/npm/axios@0.19.2/dist/axios.min.js',
// 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js', // 'https://cdn.jsdelivr.net/npm/vuex@3.1.2/dist/vuex.min.js',
// 'https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.min.js' // 'https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.min.js'
// ] // ]
// } // }
// } // }
/** /**
* 雪碧图插件 * 雪碧图插件
*/ */
const SpritesmithPlugin = require('webpack-spritesmith') const SpritesmithPlugin = require('webpack-spritesmith')
const spritesmithFunction = data => { const spritesmithFunction = data => {
let { spritesheet, sprites } = data const { spritesheet, sprites } = data
let shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}` const shared = `.sprite-icon { background-image: url(${data.sprites[0].image});background-size: ${spritesheet.width / 2}px ${spritesheet.height / 2}px;}`
let perSprite = sprites.map(sprite => { const perSprite = sprites
let { name, width, height, offset_x, offset_y } = sprite .map(sprite => {
const { name, width, height, offset_x, offset_y } = sprite
return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}` return `.icon-${name} { width: ${width / 2}px; height: ${height / 2}px; background-position: ${offset_x / 2}px ${offset_y / 2}px;}`
}).join('\n') })
.join('\n')
return `${shared}\n${perSprite}` return `${shared}\n${perSprite}`
} }
module.exports = { module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-lwk/', // 本地调试时需登录时使用 // publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-lwk/', // 本地调试时需登录时使用
// publicPath: './', // publicPath: './',
// publicPath: '/dj-scrm-wx-work-attachment-activity/', // 署应用包时的基本 URL。 vue-router history模式使用 // publicPath: '/dj-scrm-wx-work-attachment-activity/', // 署应用包时的基本 URL。 vue-router history模式使用
outputDir: 'dist', // 生产环境构建文件的目录 outputDir: 'dist', // 生产环境构建文件的目录
...@@ -59,9 +61,9 @@ module.exports = { ...@@ -59,9 +61,9 @@ module.exports = {
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。 productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: { devServer: {
disableHostCheck: true, disableHostCheck: true,
port: 9527, // 端口 port: 80, // 端口
open: false, // 启动后打开浏览器 open: false, // 启动后打开浏览器
public:'http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/#/', // public: 'http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/#/',
overlay: { overlay: {
// 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层 // 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层
warnings: false, warnings: false,
...@@ -107,15 +109,18 @@ module.exports = { ...@@ -107,15 +109,18 @@ module.exports = {
image: path.resolve(__dirname, './src/assets/images/sprite.png'), image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// 生成SCSS // 生成SCSS
css: [ css: [
[path.resolve(__dirname, './src/assets/css/sprite.scss'), { [
path.resolve(__dirname, './src/assets/css/sprite.scss'),
{
format: 'function_based_template' format: 'function_based_template'
}] }
]
] ]
}, },
customTemplates: { customTemplates: {
'function_based_template': spritesmithFunction, function_based_template: spritesmithFunction
}, },
//background引用路径 // background引用路径
apiOptions: { apiOptions: {
cssImageRef: '../images/sprite.png' cssImageRef: '../images/sprite.png'
}, },
...@@ -175,9 +180,11 @@ module.exports = { ...@@ -175,9 +180,11 @@ module.exports = {
* 打包分析 * 打包分析
*/ */
if (IS_PROD) { if (IS_PROD) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [{ config.plugin('webpack-report').use(BundleAnalyzerPlugin, [
{
analyzerMode: 'static' analyzerMode: 'static'
}]) }
])
} }
config config
// https://webpack.js.org/configuration/devtool/#development // https://webpack.js.org/configuration/devtool/#development
...@@ -187,10 +194,12 @@ module.exports = { ...@@ -187,10 +194,12 @@ module.exports = {
config config
.plugin('ScriptExtHtmlWebpackPlugin') .plugin('ScriptExtHtmlWebpackPlugin')
.after('html') .after('html')
.use('script-ext-html-webpack-plugin', [{ .use('script-ext-html-webpack-plugin', [
{
// 将 runtime 作为内联引入不单独存在 // 将 runtime 作为内联引入不单独存在
inline: /runtime\..*\.js$/ inline: /runtime\..*\.js$/
}]) }
])
.end() .end()
config.optimization.splitChunks({ config.optimization.splitChunks({
chunks: 'all', chunks: 'all',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!