Commit 17e856d0 by 李伟康

init

0 parents
Showing 84 changed files with 4599 additions and 0 deletions
> 1%
last 2 versions
# http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
insert_final_newline = false
trim_trailing_whitespace = false
NODE_ENV='development'
# must start with VUE_APP_
VUE_APP_ENV = 'development'
NODE_ENV='production'
# must start with VUE_APP_
VUE_APP_ENV = 'production'
\ No newline at end of file
NODE_ENV='production'
# must start with VUE_APP_
VUE_APP_ENV = 'staging'
build/*.js
src/assets
src/config
public
dist
module.exports = {
root: true,
env: {
node: true
},
extends: ['plugin:vue/essential', 'eslint:recommended'],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'vue/max-attributes-per-line': [
2,
{
singleline: 10,
multiline: {
max: 1,
allowFirstLine: false
}
}
],
'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off',
'vue/name-property-casing': ['error', 'PascalCase'],
'vue/no-v-html': 'off',
'accessor-pairs': 2,
'arrow-spacing': [
2,
{
before: true,
after: true
}
],
'block-spacing': [2, 'always'],
'brace-style': [
2,
'1tbs',
{
allowSingleLine: true
}
],
camelcase: [
0,
{
properties: 'always'
}
],
'comma-dangle': [2, 'never'],
'comma-spacing': [
2,
{
before: false,
after: true
}
],
'comma-style': [2, 'last'],
'constructor-super': 2,
curly: [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
eqeqeq: ['error', 'always', { null: 'ignore' }],
'generator-star-spacing': [
2,
{
before: true,
after: true
}
],
'handle-callback-err': [2, '^(err|error)$'],
indent: [
2,
2,
{
SwitchCase: 1
}
],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [
2,
{
beforeColon: false,
afterColon: true
}
],
'keyword-spacing': [
2,
{
before: true,
after: true
}
],
'new-cap': [
2,
{
newIsCap: true,
capIsNew: false
}
],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 0,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [
2,
{
allowLoop: false,
allowSwitch: false
}
],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [
2,
{
max: 1
}
],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [
2,
{
defaultAssignment: false
}
],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [
2,
{
vars: 'all',
args: 'none'
}
],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [
2,
{
initialized: 'never'
}
],
'operator-linebreak': [
2,
'after',
{
overrides: {
'?': 'before',
':': 'before'
}
}
],
'padded-blocks': [2, 'never'],
quotes: [
2,
'single',
{
avoidEscape: true,
allowTemplateLiterals: true
}
],
semi: [2, 'never'],
'semi-spacing': [
2,
{
before: false,
after: true
}
],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [
2,
{
words: true,
nonwords: false
}
],
'spaced-comment': [
2,
'always',
{
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}
],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
yoda: [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [
2,
'always',
{
objectsInObjects: false
}
],
'array-bracket-spacing': [2, 'never']
}
}
.DS_Store
node_modules
/dist
/docs
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json
yarn.lock
\ No newline at end of file
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
plugins: {
autoprefixer: {
overrideBrowserslist: ['Android 4.1', 'iOS 7.1', 'Chrome > 31', 'ff > 31', 'ie >= 8']
},
// 'postcss-pxtorem': {
// rootValue: 37.5,
// propList: ['*'],
// selectorBlackList: ['van-','ignore','ign-','.hairlines']
// },
'postcss-px-to-viewport': {
viewportWidth: 375, // 视窗的宽度,对应的是我们设计稿的宽度,一般是750
unitPrecision: 3, // 指定`px`转换为视窗单位值的小数位数(很多时候无法整除)
viewportUnit: 'vw', // 指定需要转换成的视窗单位,建议使用vw
selectorBlackList: ['.ignore', '.hairlines', 'ign-'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
mediaQuery: false // 允许在媒体查询中转换`px`
}
}
}
\ No newline at end of file
{
"printWidth": 200,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"semi": false,
"wrap_line_length": 120,
"wrap_attributes": "auto",
"proseWrap": "always",
"arrowParens": "avoid",
"bracketSpacing": true,
"htmlWhitespaceSensitivity": "ignore",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"jsxBracketSameLine": true,
"files.insertFinalNewline": true,
"useTabs": false,
"eslintIntegration": true,
"overrides": [
{
"files": ".prettierrc",
"options": {
"parser": "json"
}
}
],
"endOfLine": "auto"
}
File mode changed
This diff is collapsed. Click to expand it.
// 获取 VUE_APP_ENV 非 NODE_ENV,测试环境依然 console
const IS_PROD = ['production', 'prod'].includes(process.env.VUE_APP_ENV)
const plugins = [
[
'import',
{
libraryName: 'vant',
libraryDirectory: 'es',
style: true
},
'vant'
]
]
// 去除 console.log
if (IS_PROD) {
plugins.push('transform-remove-console')
}
module.exports = {
presets: [['@vue/cli-plugin-babel/preset', { useBuiltIns: 'usage', corejs: 3 }]],
plugins
}
{
"name": "gh-hall",
"version": "1.0.0",
"description": "GH Hall By Work WeChat",
"author": "limin <limin.mail@qq.com>",
"private": true,
"scripts": {
"serve": "vue-cli-service serve --open",
"build": "vue-cli-service build",
"stage": "vue-cli-service build --mode staging",
"lint": "vue-cli-service lint --fix",
"dev": "npm run serve"
},
"dependencies": {
"autoprefixer": "^8.0.0",
"core-js": "^3.6.4",
"dayjs": "^1.10.5",
"glsx-common": "^1.4.9",
"lib-flexible": "^0.3.2",
"postcss-loader": "^6.2.0",
"sha1": "^1.1.1",
"storejs": "^1.1.0",
"vant": "^2.12.21",
"vconsole": "^3.7.0",
"vue": "^2.6.11",
"vue-jsonp": "^2.0.0",
"vue-router": "^3.2.0",
"vuex": "^3.4.0",
"webpack-spritesmith": "^1.1.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.0",
"babel-plugin-transform-remove-console": "^6.9.4",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.14.1",
"postcss-px-to-viewport": "^1.1.1",
"postcss-pxtorem": "^5.1.1",
"sass-loader": "^8.0.2",
"script-ext-html-webpack-plugin": "^2.1.4",
"vue-loader": "^15.9.8",
"vue-template-compiler": "^2.6.11",
"webpack-bundle-analyzer": "^3.8.0"
}
}
<head>
<meta charset="utf-8">
<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">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<% 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="stylesheet" />
<% } %>
<title>
<%= webpackConfig.name %>
</title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it
to continue.</strong>
</noscript>
<div id="app"></div>
<script src="http://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<!-- 使用CDN加速的JS文件,配置在vue.config.js下 -->
<% for (var i in htmlWebpackPlugin.options.cdn&&htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
<!-- built files will be auto injected -->
</body>
</html>
\ No newline at end of file
<template>
<div id="app">
<template v-if="showWindow">
<transition name="fade">
<keep-alive v-if="$route.meta.keepAlive">
<router-view></router-view>
</keep-alive>
</transition>
<transition name="fade">
<router-view v-if="!$route.meta.keepAlive"></router-view>
</transition>
</template>
</div>
</template>
<script>
export default {
name: 'App',
data () {
return {
}
},
watch: {
watchFlag: {
immediate: true,
handler (newval) {
this.showWindow = newval
this.hideLoading()
}
}
},
computed: {
watchFlag () {
return this.$store.state.app.showWindow
}
},
mounted () {
},
methods: {}
}
</script>
\ No newline at end of file
const url = '/rop-scrm-bigdatautil/router'
import { util } from 'utils'
export default {
/**埋点 */
reportTrack (id) {
let userInfo = util.getUserInfo()
let params = util.getLocalStorage('wx_scrm_link_params')
let data = {
one_id: userInfo.openid,
staff_id: params && params.staffId || '',
staff_uuid: params && params.staffUuid,
user_phone: params && params.userPhone || '',
create_time: Date.now(),
item_type: id,
customer_phone: userInfo.phone,
action_type: 1,
item_id: 3,
business_type: 1,
add_way: 104,
merchant_id: params.merchantId
}
return window.$HTTP({
url,
data: {
method: 'entmicro.api.customercollect.reportCustomerList',
jsonList: [data]
},
})
}
}
\ No newline at end of file
/*
* @Descripttion:API 统一外部调用入口
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-17 18:23:27
*/
import ssoApi from './ssoApi'
import mapApi from './mapApi'
import wxConfig from './wxConfig'
import shopmallApi from './shopmallApi'
import bigdatautilApi from './bigdatautilApi'
export {
ssoApi,
mapApi,
wxConfig,
shopmallApi,
bigdatautilApi
}
\ No newline at end of file
import md5 from './utils/md5'
import qs from './utils/qs'
const key = 'F2HBZ-KH73F-7A2J2-JC4UR-WOHCO-UVFGZ'
const secret = 'YBmrM98E5pM4gYeknWiBPaWpFR4AISUl'
const domain = 'https://apis.map.qq.com'
class QQMap {
setLocaleCompare (params) {
params.key = key
let keys = []
let obj = {}
Object.keys(params).map(e => keys.push(e))
keys.sort((a, b) => a.localeCompare(b)).map(e => obj[e] = params[e])
return obj
}
getSign (params, methods) {
let obj = this.setLocaleCompare(params)
let sign = `${methods}?${decodeURIComponent(qs.stringify(obj))}${secret}`
return md5(sign)
}
request (method, data) {
data.output = 'jsonp'
// data.callback = 'test'
const sig = this.getSign(data, method)
let obj = {
...this.setLocaleCompare(data),
sig
}, params = []
Object.keys(obj).map(key => {
params.push(`${key}=${encodeURIComponent(obj[key])}`)
})
// window.fetch(`${domain}${method}?${params.join('&')}`, {
// method: RequestMethods,
// mode: 'no-cors',
// data: `${params.join('&')}`
// })
let script = document.createElement('script')
script.src = `${domain}${method}?${params.join('&')}`
script.type = "text/javascript"
document.body.insertBefore(script, document.body.children[0])
return new Promise((resolve, reject) => {
window['QQmap'] = ({ status, result }) => {
if (status == '0') resolve(result)
else reject()
document.body.removeChild(script)
}
})
}
/**计算距离 */
calculateDistance (from, to) {
from = from.join(',')
to = to.join(',')
return this.request('/ws/distance/v1/', {
from,
to,
mode: 'driving'
})
}
/** 批量距离计算(矩阵) */
calculateDistanceMatrix (from, toList) {
from = from.join(',')
let to = toList.join(';')
return this.request('/ws/distance/v1/matrix/', {
from,
to,
mode: 'driving'
})
}
/**地址解析(地址转坐标) */
geocoder (address) {
return this.request('/ws/geocoder/v1/', {
address
})
}
/**逆地址解析(坐标位置描述) location=lat<纬度>,lng<经度> */
detailedAdrress (location) {
location = location.join(',')
return this.request('/ws/geocoder/v1/', {
location
})
}
/**IP定位 */
getLocationByIp () {
return this.request('/ws/location/v1/ip')
}
/**坐标转换 */
translate (locations, type = 5) {
locations = locations.join(';') //格式:纬度前,经度后
return this.request('/ws/coord/v1/translate', {
locations,
type
})
}
}
export default new QQMap()
\ No newline at end of file
const url = '/rop-scrm-shopmall/router'
export default {
/** */
getActivityDetail (id) {
return window.$HTTP({
url,
data: {
method: 'scrm.api.shopmall.weapp.activity.detail',
id
}
})
},
getActivityGroup (id) {
return window.$HTTP({
url,
data: {
method: 'scrm.api.shopmall.weapp.activity.group',
id
}
})
},
/** 创建订单(立即购买) */
createOrder (data) {
data.method = 'scrm.api.shopmall.weapp.order.create'
return window.$HTTP({
url,
data,
})
},
/**创建支付订单(去付款) */
payOrder (data) {
data.method = `scrm.api.shopmall.weapp.order.createPay`
return window.$HTTP({
url,
data,
returnAll: true
})
},
}
\ No newline at end of file
const url = '/rop-scrm-sso/router'
const returnAll = true
export default {
/**OAuth2授权登陆 */
login(data) {
data.method = 'scrm.api.sso.weapp.login.by.wechat'
return window.$HTTP({
url,
data,
returnAll
})
}
}
\ No newline at end of file
import util from '@/utils/util'
import { Notify } from 'vant'
const WxConfig = {
init (jsApiList) {
return new Promise((resolve, reject) => {
jsApiList.map(e => {
if (e == 'chooseImage') jsApiList.push('getLocalImgData')
})
let [redirectUrl] = window.location.href.split('#')
let appId = util.getAppId()
return window.$HTTP({
url: '/rop-scrm-equity/router',
data: {
url: redirectUrl,
appId,
method: 'scrm.api.equity.common.wechat.jsconfig'
}
}).then(data => {
if (data) {
let obj = {}
Object.keys(data).map(key => {
if (data[key]) obj[key] = data[key]
})
wx.config({
...obj,
jsApiList,
openTagList: ['wx-open-launch-weapp']
})
resolve()
} else {
reject()
Notify('网络异常')
}
})
})
},
ready (callBack) {
return new Promise((resolve, reject) => {
wx.ready(() => {
callBack(resolve, reject)
})
})
},
/**获取地理位置接口 */
getLocation (type = 'gcj02') {
console.log(type)
return this.ready((resolve) => {
wx.getLocation({
type, // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success (res) {
resolve(res)
}
})
})
},
openLocation (params) {
return this.ready(resolve => {
let { latitude, longitude, name, address, scale = '18', infoUrl = '' } = params
wx.openLocation({
latitude,
longitude,
name,
address,
scale,
infoUrl,
success (res) {
console.log(res)
resolve(res)
}
})
})
},
/**支付 */
chooseWXPay ({ timestamp, nonceStr, packages, signType, paySign }) {
return this.ready(resolve => {
wx.chooseWXPay({
timestamp, // 支付签名时间戳,注意微信js sdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
nonceStr, // 支付签名随机串,不长于 32 位
package: packages, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
paySign, // 支付签名
success (res) {
window.vm.showToast('支付成功')
resolve(res)
},
fail () {
window.vm.showToast('已取消支付')
},
cancel () {
window.vm.showToast('支付失败,请重试')
}
})
})
},
updateAppMessageShareData (params) {
// title, // 分享标题
// desc: '', // 分享描述
// link: '', // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
// imgUrl: '', // 分享图标
return this.ready(resolve => {
wx.updateAppMessageShareData({
...params,
success: function () {
resolve()
// 设置成功
}
})
})
}
}
export default WxConfig
@keyframes move {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
.layout {
padding-bottom: 100px;
.to-top {
position: fixed;
right: 10px;
bottom: 100px;
z-index: 2;
width: 30px;
height: 30px;
overflow: hidden;
background-color: #fff;
border-radius: 100%;
}
.kf {
position: fixed;
right: 8px;
top: 402px;
z-index: 2;
}
.big-img {
position: relative;
width: 100%;
overflow: hidden;
.hot {
height: 26px;
background: rgba(0, 0, 0, 0.5);
border-radius: 13px;
padding: 0 10px;
text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4);
font-weight: 600;
font-size: 12px;
color: #ffffff;
top: 8px;
.icon-hot {
margin-right: 2px;
}
}
.music {
position: absolute;
top: 40px;
right: 20px;
.icon-music {
animation: move 3s infinite ease-in-out;
}
}
}
.video {
width: 268px;
height: 150px;
margin: 10 auto 10px;
}
.video-title {
font-size: 14px;
font-weight: 500;
color: #2C2C2C;
padding-left: 16px;
span {
font-weight: 400;
color: #656566;
font-size: 12px;
}
}
.video-box {
padding: 8px 0 10px;
flex-wrap: nowrap;
overflow-x: scroll;
.item {
flex-shrink: 0;
margin-left: 16px;
width: 129px;
height: 72px;
border-radius: 2px;
background: linear-gradient(bottom, #000 0%, #fff 100%);
&:last-of-type {
margin-right: 16px;
}
}
}
.box {
background: #ffffff;
border-radius: 8px;
box-sizing: border-box;
padding: 14px 10px;
margin-bottom: 10px;
.title {
font-size: 14px;
font-weight: 600;
color: #fc5b32;
text-align: center;
position: relative;
}
}
.activity {
padding: 0 16px;
.address-box {
font-size: 12px;
color: #656566;
display: flex;
justify-content: space-between;
margin-top: 8px;
.address-info {
width: calc(100% - 64px);
.name {
color: #2c2c2c;
font-weight: 500;
font-size: 14px;
line-height: 20px;
}
.time {
margin-top: 8px;
color: #fc5b32;
}
}
.address-btn {
margin: 3px 0 0 auto;
.icon-address{
margin: 0 auto;
}
}
}
.group-title {
font-size: 16px;
font-weight: 600;
color: #3C3939;
text-align: center;
position: relative;
margin-bottom: 14px;
span {
color: #FC5B32;
}
.view {
position: absolute;
right: 0;
bottom: 0;
font-weight: 400;
font-size: 10px;
}
}
.group-box {
padding: 0 9px;
display: flex;
flex-wrap: wrap;
width: 100%;
max-height: 216px;
box-sizing: border-box;
overflow-y: scroll;
.item {
font-size: 12px;
color: #3C3939;
text-align: center;
width: 20%;
}
img {
width: 45px;
height: 45px;
margin-bottom: 2px;
border-radius: 100%;
overflow: hidden;
}
}
.progress-bar {
margin: 24px 16px 8px;
position: relative;
.progress {
width: 100%;
height: 14px;
border-radius: 7px;
background: #FFE9E4;
overflow: hidden;
.line {
width: 0;
height: 100%;
background: linear-gradient(270deg, #FF8802 0%, #FC5B32 100%);
transition: all .25s;
font-size: 12px;
font-weight: 600;
color: #FFFFFF;
justify-content: flex-end;
box-sizing: border-box;
border-radius: 7px;
}
.line-padding{
padding-right: 14px;
}
}
.bar {
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
}
}
.group-info {
padding: 0 16px;
justify-content: space-between;
font-size: 12px;
font-weight: 500;
color: #3C3939;
.item {
color: #FC5B32;
}
}
}
}
\ 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
@import './normalize.scss';
@import './sprite.scss';
html,
body .app {
color: #333333;
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
background-color:#F7F8FA;
-webkit-overflow-scrolling: touch;
height: 100%;
// overflow: hidden;
--themeColor: #3975C6;
}
img {
width: 100%;
height: 100%;
vertical-align: top;
}
video{
width: 100%;
height: 100%;
}
.flex {
display: flex;
align-items: center;
}
.text-hide {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.text-two-line {
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 2;
display: -webkit-box;
-webkit-box-orient: vertical;
}
.text-center {
display: flex;
align-items: center;
justify-content: center;
}
.x-center {
position: absolute;
left: 50%;
transform: translateX(-50%);
}
.y-center {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.xy-center{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
.sprite-icon { background-image: url(../images/sprite.png);background-size: 453px 364px;}
.icon-address { width: 34px; height: 34px; background-position: -310px -232px;}
.icon-flash { width: 20px; height: 20px; background-position: -430px -276px;}
.icon-hot { width: 15px; height: 18px; background-position: -404px -316px;}
.icon-kf { width: 56px; height: 70px; background-position: -390px -152px;}
.icon-music-off { width: 34px; height: 34px; background-position: -354px -232px;}
.icon-music { width: 32px; height: 32px; background-position: -398px -232px;}
.icon-order { width: 20px; height: 20px; background-position: -344px -316px;}
.icon-poster { width: 20px; height: 20px; background-position: -374px -316px;}
.icon-time { width: 12px; height: 11px; background-position: -429px -316px;}
.icon-title { width: 170px; height: 4px; background-position: 0px -360px;}
.icon-top { width: 30px; height: 30px; background-position: -310px -276px;}
.icon-success { width: 70px; height: 70px; background-position: -310px -152px;}
.icon-close { width: 24px; height: 24px; background-position: -310px -316px;}
.icon-download { width: 30px; height: 30px; background-position: -350px -276px;}
.icon-kf-box { width: 300px; height: 350px; background-position: 0px 0px;}
.icon-phone { width: 12px; height: 13px; background-position: -440px -232px;}
.icon-qr { width: 143px; height: 142px; background-position: -310px 0px;}
.icon-scan { width: 30px; height: 30px; background-position: -390px -276px;}
\ No newline at end of file
<template>
<div
class="action isFullSucreen flex"
v-if="show"
>
<div class="btn-box flex">
<div class="item">
<div class="sprite-icon icon-order"></div>
订单
<wx-open-launch-weapp
class="mini"
path="packageMine/pages/order/index/index.html"
username="gh_21f69fe893fc"
:env-version="envVersion"
>
<script type="text/wxtag-template">
<div class="mini-btn">点击跳转</div>
</script>
</wx-open-launch-weapp>
</div>
<div
class="item"
@click="showPoster = true"
>
<div class="sprite-icon icon-poster"></div>
海报
</div>
</div>
<div class="price">
<span class="unit">¥</span>{{detail.price}}<span>.{{detail.decimal}}</span>
<template v-if="detail.buyFlag == 3">
<span>参团成功</span>
</template>
</div>
<div
:class="['btn text-center',{'disabled':disabled},{'short':detail.buyFlag == 3}]"
@click="showModal = true"
>
<template v-if="detail.activityStatus == 1">敬请期待</template>
<template v-else-if="detail.activityStatus == 3">活动已结束</template>
<template v-else>
<template v-if="detail.buyFlag == 3">继续参团</template>
<template v-else>立即参团</template>
</template>
</div>
<pay-modal
v-model="showModal"
:list="formList"
@cancel="showModal = false"
@pay="checkOut"
:payStatus="payStatus"
/>
<van-overlay
:show="showPoster"
@click.self="showPoster = false"
>
<div
class="wrapper"
@click.stop
>
<van-image
:src="detail.posterImg"
width="100%"
height="100%"
>
<template v-slot:loading>
<van-loading
type="spinner"
size="20"
/>
</template>
</van-image>
</div>
</van-overlay>
</div>
</template>
<script type='text/ecmascript-6'>
import { shopmallApi, wxConfig } from '@/api'
import { util } from '@/utils'
export default {
name: 'Action',
props: ['detail'],
watch: {
'detail': function (n) {
this.show = true
if (n) {
let [price, decimal] = this.centsToyuan(n.retailPrice).toString().split('.')
if (!decimal) decimal = '00'
n.price = price
n.decimal = decimal
// limitPurchaseFlag 是否限购标志:1 否;2 是;
//buyFlag 1是未购买或者未限购,2是已购买且达到购买上限,3是已购买且未达到购买上限
this.disabled = n.activityStatus == 3 || n.buyFlag == 2
this.formList = [{
key: 'formDescribeFirst',
maxlength: 40,
name: n.formDescribeFirst
}, {
key: 'formDescribeSecond',
maxlength: 40,
name: n.formDescribeSecond
}, {
key: 'formDescribeThird',
maxlength: 40,
name: n.formDescribeThird
}]
}
}
},
data () {
return {
show: false,
disabled: false,
showModal: false,
showPoster: false,
formList: [],
payStatus: Date.now(),
envVersion: 'release'
}
},
mounted () {
const { envVersion } = window.$fetchConfig
this.envVersion = envVersion
// shopmallApi.payOrder({
// orderCode:2207101414289656
// })
},
methods: {
checkOut: util.debounce(({ obj, that }) => {
let { detail, disabled } = that
if (disabled || detail.activityStatus == 1) return
let { nickName, logo } = util.getUserInfo()
let linkParams = util.getLocalStorage('wx_scrm_link_params') || {}
let params = {
...obj,
contactAddress: ' ',
contactName: ' ',
contactPhone: ' ',
activityId: detail.id,
orderSource: 4,
imageUrl: logo,
nickName,
orderGoodsList: [{
goodsId: detail.goodsId,
activityPrice: detail.retailPrice * 100,
goodsNumber: 1
}],
shareStaffName: linkParams.staffName || '',
shareStaffUuid: linkParams.staffUuid || '',
shareStaffType: linkParams.staffType || ''
}
shopmallApi.createOrder(params).then(data => {
that.pay(data.orderCode)
})
}, 1e3),
pay (orderCode) {
this.showLoading('结算中')
shopmallApi.payOrder({
orderCode
}).then(({ code, data, message }) => {
this.hideLoading()
this.payStatus = Date.now()
if (code == '0') {
this.showModal = false
let { needPay, payParams } = data
if (needPay) {
let params = {
nonceStr: payParams.nonceStr,
paySign: payParams.paySign,
signType: payParams.signType,
timestamp: payParams.timeStamp,
packages: payParams.packages
}
wxConfig.chooseWXPay(params).then(() => this.$router.push({ name: 'crowdfunding.success' }))
} else this.$router.push({ name: 'crowdfunding.success' })
} else this.showToast(message)
})
}
}
}
</script>
<style scoped lang='scss'>
@keyframes showAction {
form {
bottom: -100%;
}
to {
bottom: 0;
}
}
.action {
position: fixed;
left: 0;
width: calc(100% - 32px);
height: 50px;
background: #ffffff;
z-index: 2;
padding: 0 16px;
animation: showAction 0.5s forwards;
.btn-box {
font-size: 10px;
color: #656566;
.item {
margin-right: 16px;
width: 20px;
height: 35px;
position: relative;
overflow: hidden;
.mini {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 2;
opacity: 0;
&-btn {
width: 100%;
height: 100%;
}
}
}
}
.price {
font-weight: 600;
color: #f13c3d;
font-size: 20px;
display: flex;
align-items: baseline;
.unit {
font-size: 12px;
}
span {
font-size: 14px;
}
}
.btn {
width: 200px;
height: 40px;
background: #f13c3d;
box-shadow: 0px 2px 6px 2px rgba(241, 60, 61, 0.1);
border-radius: 4px;
border: 1px solid #f13c3d;
margin-left: auto;
font-size: 14px;
font-weight: 500;
color: #ffffff;
box-sizing: border-box;
}
.disabled {
background: #b1b1b1;
border-color: #b1b1b1;
box-shadow: none;
}
.short {
width: 150px;
}
}
.isFullSucreen {
padding-bottom: constant(safe-area-inset-bottom) !important;
padding-bottom: env(safe-area-inset-bottom) !important;
}
.wrapper {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 270px;
height: 555px;
background: #ffffff;
box-shadow: 0px 2px 8px 0px rgba(201, 202, 204, 0.5);
border-radius: 4px;
}
</style>
\ No newline at end of file
<template>
<van-overlay
:show="show"
>
<div
class="wrapper"
@click.self="cancel"
>
<div class="kf-box flex">
<div class="sprite-icon icon-kf-box"></div>
<div class="sprite-icon icon-kf x-center"></div>
<div class="info">
<div class="name">{{detail.customerServiceName}}</div>
<div class="phone flex" @click="makePhoneCall(detail.customerServicePhone)">
<div class="sprite-icon icon-phone"></div>{{detail.customerServicePhone}}
</div>
</div>
<div class="qr-box">
<div class="sprite-icon icon-qr"></div>
<img
:src="detail.customerServiceQrImg"
class="qr xy-center"
/>
</div>
<div class="bottom flex">
<div class="item flex">
<div class="sprite-icon icon-download"></div>
<div>保存图片<br>到相册</div>
</div>
<div class="item flex">
<div class="sprite-icon icon-scan"></div>
<div>打开微信扫一扫<br>添加客服企微</div>
</div>
</div>
</div>
</div>
</van-overlay>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'KfModal',
props: ['value', 'detail'],
data () {
return {
show: false,
img: null
}
},
mounted () { },
watch: {
value (n) {
this.show = n
}
},
methods: {
cancel () {
console.log(123)
this.show = false
this.$parent.showKf = false
},
save () {
this.showToast('请长按二维码保存')
}
}
}
</script>
<style scoped lang='scss'>
.van-overlay {
z-index: 2;
}
.wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
flex-direction: column;
.kf-box {
width: 300px;
height: 350px;
position: relative;
flex-direction: column;
font-size: 18px;
font-weight: 500;
color: #282829;
.icon-kf-box {
position: absolute;
}
.icon-kf {
top: -15px;
}
.info {
position: relative;
z-index: 2;
text-align: center;
padding-top: 64px;
.phone {
letter-spacing: 2px;
margin-top: 1px;
}
}
.qr-box {
position: relative;
width: 143px;
height: 142px;
margin: 10px 0 16px;
.qr {
width: calc(100% - 32px);
height: calc(100% - 32px);
}
}
.bottom {
position: absolute;
left: 0;
bottom: 0;
z-index: 2;
width: 100%;
height: 70px;
background: #f7f8fa;
border-radius: 0px 0px 10px 10px;
box-sizing: border-box;
padding: 0 20px;
justify-content: space-between;
.item {
padding-left: 7px;
font-size: 12px;
color: #b1b1b3;
.sprite-icon {
margin-right: 6px;
}
}
}
}
}
</style>
\ No newline at end of file
<template>
<van-action-sheet
v-model="showBox"
@click-overlay="onCancel"
>
<div class="box">
<template v-for="(i,index) in items">
<template v-if="i.name">
<div
class="item"
:key="index"
>
<div class="label">
<span>*</span>
{{i.name}}
</div>
<div class="value">
<van-field
v-model="params[i.key]"
:placeholder="`请填写您的${i.name}`"
:maxlength="i.maxlength"
:type="i.type"
/>
</div>
</div>
</template>
</template>
<van-button
color="#f13c3d"
class="btn"
@click="pay"
loading-text="支付中..."
:loading="payLoading"
>立即支付</van-button>
</div>
</van-action-sheet>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'PayModal',
props: {
value: Boolean,
list: {
type: Array,
default: () => []
},
payStatus: Number
},
watch: {
value (n) {
let { phone } = this.getUserInfo()
this.showBox = n
if (n) {
this.items = [
{ name: '姓名', key: 'userName', maxlength: 40 },
{ name: '电话', key: 'userPhone', maxlength: 11, type: 'tel' },
...this.list
]
if (!this.params.userPhone) this.params.userPhone = phone
}
},
payStatus (n) {
this.payLoading = false
}
},
data () {
return {
showBox: false,
payLoading: false,
items: [],
params: {
userName: '',
userPhone: '',
formDescribeFirst: '',
formDescribeSecond: '',
formDescribeThird: ''
}
}
},
mounted () {
},
methods: {
onCancel () {
this.$emit('cancel')
},
pay () {
let { params, items } = this,
obj = {},
phoneRex = /^[1]([3-9])[0-9]{9}$/
try {
items.map(e => {
Object.keys(params).map(key => {
if (!params[key] && key == e.key && e.name) throw e.name
})
})
} catch (error) {
this.showToast(`请填写${error}`)
return
}
if (!phoneRex.test(params.userPhone)) {
this.showToast('请输入正确的手机号')
return
}
Object.keys(params).map(key => {
if (params[key]) obj[key] = params[key]
})
this.payLoading = true
this.$emit('pay', { obj, that: this.$parent })
}
}
}
</script>
<style scoped lang='scss'>
.box {
padding: 26px;
.item {
margin-bottom: 15px;
.label {
font-size: 16px;
font-weight: 500;
color: #282829;
span {
color: #f13c3d;
}
}
.value {
border-bottom: 1px solid #e3e3e6;
/deep/.van-field {
padding: 8px 0;
font-size: 14px;
}
}
}
.btn {
display: block;
font-size: 16px;
font-weight: 600;
color: #ffffff;
width: 310px;
height: 44px;
box-shadow: 0px 2px 6px 2px rgba(241, 60, 61, 0.1);
border-radius: 4px;
border: 1px solid #f13c3d;
margin: 0 auto;
}
}
</style>
\ No newline at end of file
<template>
<van-tabbar
route
@change="change"
v-model="value"
:border="false"
:safe-area-inset-bottom="true"
>
<template v-for="(i,index) in data">
<van-tabbar-item
:key="index"
replace
:to="`/${i.name}`"
:name="i.name"
>
{{i.title}}
<template #icon="props">
<img :src="props.active ? i.active : i.inactive" />
</template>
</van-tabbar-item>
</template>
</van-tabbar>
</template>
<script>
export default {
name: 'TabBar',
props: {
data: {
type: Array,
default: () => {
return []
}
}
},
data () {
return {
value: ''
}
},
methods: {
change (value) {
this.$emit('change', value)
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang='scss'>
.van-tabbar {
box-shadow: 0px -2px 4px 0px rgba(0, 0, 0, 0.1), 0px 0px 0px 0px #e5e5e5;
.van-tabbar-item--active {
color: var(--themeColor);
}
.van-tabbar-item__icon img {
width: 20px;
height: 20px;
}
}
</style>
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-08 19:20:13
* @LastEditors: limin
* @LastEditTime: 2021-06-25 18:09:28
*/
import Vue from 'vue'
const componentsFiles = require.context(`./`, true, /.vue$/)
componentsFiles.keys().forEach(path => {
const component = componentsFiles(path).default
Vue.component(component.name, component)
})
// export default [Icon, NavBar, TabBar, Organization, CustomerList, CustomerDetail, OrderList, OrderDetail, TimerTabs, CarType, RadioCell, CheckBoxCell, ValidateField]
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-08 16:55:43
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
const environment = process.env.VUE_APP_ENV || 'production'
let config = require('./env.' + environment)
module.exports = config
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-28 10:13:38
*/
// 本地环境配置
module.exports = {
envVersion: 'trial',
title: '加载中...',
request: {
baseURL: 'http://scrm.dev.glsx.com.cn', // 本地测试项目地址,
// 设置超时时间
timeout: 180000,
// 携带凭证
withCredentials: true,
// 返回数据类型
responseType: 'json'
},
response: {
data_key: 'data',
message_key: 'message',
code_key: 'code',
code_success_value: '0',
errId_logout_value: '21',
logout_function: 'reLogin',
code_message_map: {}
},
secret: "c24619ed7fef02a0ae16328146bca5f97cc6493957a2137b",
// shopmall_appid: "wxfe82b8d65d07808f", //广汇
shopmall_appid: "wxe10067a63c1856ac", //嘀加
sign: {
appKey: "48e5e13229b82c1b4e6e8c96151f0637",
format: "json",
locale: "zh_CN",
source: "scrm-main",
v: "1.0.0",
},
vconsole: false
}
\ No newline at end of file
module.exports = {
title: '嘀加企微管家',
request: {
// baseURL: 'http://ghwx.cgacar.com/scrm-wechat' // 生产
baseURL: 'http://cim.chinagrandauto.com/scrm-wechat' // 生产
// baseURL: 'http://cim.chinagrandauto.com' // 生产
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file
module.exports = {
title: '嘀加企微管家',
request: {
baseURL: 'http://xxxxx' // 项目地址
},
APPID: 'xxx',
APPSECRET: 'xxx',
cdn: 'https://www.xxx.cn/static'
}
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-30 11:23:25
*/
// 根据环境引入不同配置 process.env.VUE_APP_ENV
let config = require('./conf.js')
let timeout = 30000 //超时时间
export const fetchConfig = function(isEnv = true) {
if (isEnv) {
let { request } = config
Object.assign(request, { timeout })
return Promise.resolve(config)
}
return window.fetch('https://oss-config.dev.glsx.com.cn/mock/618cb9331072f92988f05a23/wx/config', {}).then(res => res.json())
}
export const cfg = {
install(vue, config) {
vue.prototype.$config = config
}
}
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-29 15:35:47
*/
// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
// import 'core-js/stable'
// import 'regenerator-runtime/runtime'
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import api from './api'
import { fetchConfig, cfg } from '@/config'
import '@/assets/css/index.scss'
import { bus, tools, store as local, util } from './utils'
import './utils/util'
import 'components'
import { components } from '@/plugins/vant'
import { VueJsonp } from 'vue-jsonp'
Vue.use(VueJsonp)
components.forEach(component => Vue.use(component))
Vue.prototype.api = api
Vue.prototype.bus = bus
Vue.prototype.tools = tools
Vue.prototype.local = local
Vue.prototype.to = function (name, params) {
if (name === -1) {
router.go(-1)
return
}
router.push({ name, params })
}
// 移动端适配 rem
// import 'lib-flexible/flexible.js'
import VConsole from 'vconsole'
const isMock = ['prod', 'production'].includes(process.env.NODE_ENV)
fetchConfig(!isMock).then(res => {
// 从配置服务器获取动态配置
// 设置 js中可以访问 $cdn
Vue.use(cfg)
window.$fetchConfig = res
if (res.vconsole) new VConsole()
console.log(res)
/**登录过期 重新登录 */
window.reLogin = () => {
console.log('重新登录')
util.clearSessionId()
store.dispatch('navigation')
}
window.vm = new Vue({
el: '#app',
router,
store,
render: h => h(App)
})
})
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
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
import shareMixin from './shareMixin'
import pageMixin from './pageMixin'
import discountTypeMixin from './discountTypeMixin'
export {
shareMixin,
pageMixin,
discountTypeMixin
}
\ No newline at end of file
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
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)
})
}
}
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-23 11:44:59
*/
// 按需全局引入 vant组件
import {
Button,
List,
Cell,
Tabbar,
TabbarItem,
NavBar,
Search,
ActionSheet,
CellGroup,
Image as VanImage,
Tag,
Field,
Stepper,
Divider,
Step,
Steps,
NoticeBar,
RadioGroup,
Radio,
Uploader,
Tab,
Tabs,
DropdownMenu,
DropdownItem,
Grid,
GridItem,
Popup,
Calendar,
Cascader,
Checkbox,
CheckboxGroup,
Notify,
Icon,
Empty,
PullRefresh,
Picker,
Dialog,
ShareSheet,
Overlay,
loading,
SwipeCell
} from 'vant'
export const components = [
Button,
List,
Cell,
Tabbar,
TabbarItem,
NavBar,
Search,
ActionSheet,
CellGroup,
VanImage,
Tag,
Field,
Stepper,
Divider,
Step,
Steps,
NoticeBar,
RadioGroup,
Radio,
Uploader,
Tab,
Tabs,
DropdownMenu,
DropdownItem,
Grid,
GridItem,
Popup,
Calendar,
Cascader,
Checkbox,
CheckboxGroup,
Notify,
Icon,
Empty,
PullRefresh,
Picker,
Dialog,
ShareSheet,
Overlay,
loading,
SwipeCell
]
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-09 17:11:43
*/
import router from './router'
import { keeps } from './routes'
export const keepAlives = keeps
export default router
import Vue from 'vue'
import Router from 'vue-router'
import routes from './routes'
import store from '@/store'
// hack router push callback
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
Vue.use(Router)
const router = createRouter()
function createRouter() {
return new Router({
// mode: 'history', // 如果是 history模式 需要配置vue.config.js publicPath
base: process.env.BASE_URL,
scrollBehavior: function (to, from, savedPosition) {
return savedPosition || { x: 0, y: 0 }
},
routes
})
}
// http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-attachment-activity/
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
store.dispatch('setPageMeta', to.meta)
} else {
store.dispatch('setPageMeta', { title: '加载中...' })
}
store.commit('SET_LAST_PATH', to.name)
/* 路由发生变化修改页面背景色 */
if (to.meta.backgroundColor) document.documentElement.style.backgroundColor = to.meta.backgroundColor
if (to.matched.some(recode => recode.meta.noAuth)) {
store.state.app.showWindow = true
} else {
store.dispatch('navigation')
}
next()
})
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router
const pages = {
crowdfunding: [
{
name: 'index',
meta: {
keepAlive: true,
backgroundColor: '#F7F7F7'
},
},
{
name: 'success',
meta: {
keepAlive: true,
backgroundColor: '#FFF',
noAuth: true,
title: '参团成功'
},
}
]
}
let routes = [
{
path: '/',
redirect: '/crowdfunding'
}
]
const keepAlives = []
Object.keys(pages).map(parent => {
pages[parent].map(val => {
let childrenPath = `${parent}/${val.name}`
let { meta } = val
const path = `/${val.name == 'index' ? parent : childrenPath}`
const name = val.name == 'index' ? parent : childrenPath.replace('/', '.')
if (meta && meta.keepAlive) keepAlives.push(name)
let route = {
component: resolve => require([`views/${childrenPath}.vue`], resolve),
path,
name,
meta
}
routes.push(route)
})
})
export const keeps = keepAlives
export default routes
\ No newline at end of file
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:54
* @FilePath: \gh-hall\src\store\getters.js
*/
const getters = {
app: state => state.app
}
export default getters
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
// import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
app
},
getters
// plugins: [createPersistedState({
// //指定存储模式
// storage: window.sessionStorage
// })]
})
export default store
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-07-06 12:02:21
*/
import { ssoApi } from '@/api'
import { store, util } from 'utils'
import { Http } from 'glsx-common'
import { Notify } from 'vant'
const state = {
pageMeta: '',
keepAlives: [],
lastPath: ''
}
const mutations = {
SET_PAGE_META (state, meta) {
state.pageMeta = meta
},
PUSH_KEEP (state, name) {
if (!state.keepAlives.includes(name)) {
state.keepAlives.push(name)
}
},
REMOVE_KEEP (state, names) {
state.keepAlives = state.keepAlives.reduce((arr, name) => {
if (!names.includes(name)) {
return arr.push(name)
}
return arr
}, [])
},
SET_LAST_PATH (state, path) {
state.lastPath = path
}
}
const actions = {
setPageMeta ({ commit }, meta) {
document.title = meta.title
commit('SET_PAGE_META', meta)
},
pushKeep ({ commit }, name) {
commit('PUSH_KEEP', name)
},
removeKeep ({ commit }, names) {
commit('REMOVE_KEEP', names)
},
login ({ dispatch }) {
let [redirectUrl] = window.location.href.split('?')
const code = getParams('code')
if (code) {
const appId = util.getAppId()
ssoApi
.login({
code,
appId,
state: 'snsapi_userinfo'
})
.then(({ code, data, message }) => {
let route = state.lastPath == 'crowdfunding' ? '' : state.lastPath || ''
route = route.replace('.', '/')
if (code == '0') {
util.setUserInfo(data)
util.setSessionId(data.sessionId)
dispatch('registerHttp', data.sessionId)
state.showWindow = true
window.location.replace(`${redirectUrl}#/${route}`)
} else {
Notify(message)
}
})
} else {
let params = getParams() //从链接获取
if (Object.keys(params).length) util.setLocalStorage('wx_scrm_link_params', params)
util.showLoading()
let appid = 'wx56bed167ad463f70'
util.setAppId(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_userinfo&state=STATE#wechat_redirect`
}
},
navigation ({ dispatch }) {
const storage_sessionId = util.getSessionId()
if (storage_sessionId) {
state.showWindow = true
dispatch('registerHttp', 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 => {
let [url, paramsList] = window.location.href.split('?')
if (!paramsList) return name ? null : {}
let param = paramsList.split('&')
let obj = {}
param.map(e => {
let [key, value] = e.split('=')
obj[key] = value
})
return name ? obj[name] : obj
}
export default {
state,
mutations,
actions
}
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-15 14:41:02
* @LastEditors: limin
* @LastEditTime: 2021-06-15 14:45:39
*/
export const STORE_USER_KEY = 'STORE_USER_KEY'
/*
* @Descripttion:
* @version: 1.0.0
* @Author: limin
* @Date: 2021-06-09 17:01:55
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:18
* @FilePath: \gh-hall\src\utils\eventBus.js
*/
/**
* eventBus,事件总线,可以在任意组件之间实现事件通信
* 使用方法,使用下面的两行代码即可创建一个 eventBus,创建好以后在 main,js 中引入
* 并通过 Vue.prototype.bus = bus 将 eventBus 挂载到 vue 的原型上就可以全局使用 eventBus 了
*
* 发送事件:在触发事件的地方使用 $emit 来发送事件
* this.bus.$emit(‘事件名’,eventData)
*
* 接收事件:在需要接收事件的地方使用 $on 来接收事件
* this.bus.$on(‘事件名’,(eventData)=>{
console.log(eventData)
})
*
* 注销事件:$emit 定义的事件必须要在组件销毁之前注销,不然事件会一直触发
* beforeDestroy() {
this.bus.$off(‘事件名’);
},
*/
import Vue from 'vue'
export default new Vue()
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-07 14:12:32
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:11
*/
import bus from './eventBus'
import util from './util'
import * as tool from './tools'
const { debounce, throttle, ...tools } = tool
import * as constants from './constants'
import store from './store'
export { bus, tools, debounce, throttle, constants, store, util }
\ No newline at end of file
/*
* @Descripttion:
* @version:
* @Author: limin
* @Date: 2021-06-15 14:46:31
* @LastEditors: limin
* @LastEditTime: 2021-06-20 12:49:04
*/
import store from 'storejs'
export default {
...store,
exp: {
set: function(key, val, exp = 24 * 60 * 60 * 1000) {
store.set(key, { val: val, exp: exp, time: new Date().getTime() })
},
get: function(key) {
var info = store.get(key)
if (!info) {
return null
}
if (new Date().getTime() - info.time > info.exp) {
store.remove(key)
return null
}
return info.val
}
},
consts: {
USER_KEY: 'USER_KEY',
}
}
\ No newline at end of file
/**
* Parse the time to string
* @param {(Object|string|number)} time
* @param {string} cFormat
* @returns {string}
*/
export function parseTime(time, cFormat) {
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'object') {
date = time
} else {
if (typeof time === 'string' && /^[0-9]+$/.test(time)) {
time = parseInt(time)
}
if (typeof time === 'number' && time.toString().length === 10) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') {
return ['日', '一', '二', '三', '四', '五', '六'][value]
}
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
}
/**
* @param {number} time
* @param {string} option
* @returns {string}
*/
export function formatTime(time, option) {
if (('' + time).length === 10) {
time = parseInt(time) * 1000
} else {
time = +time
}
const d = new Date(time)
const now = Date.now()
const diff = (now - d) / 1000
if (diff < 30) {
return '刚刚'
} else if (diff < 3600) {
// less 1 hour
return Math.ceil(diff / 60) + '分钟前'
} else if (diff < 3600 * 24) {
return Math.ceil(diff / 3600) + '小时前'
} else if (diff < 3600 * 24 * 2) {
return '1天前'
}
if (option) {
return parseTime(time, option)
} else {
return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
}
}
/**
* @param {string} url
* @returns {Object}
*/
export function param2Obj(url) {
const search = url.split('?')[1]
if (!search) {
return {}
}
return JSON.parse(
'{"' +
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')
.replace(/\+/g, ' ') +
'"}'
)
}
export function debounce(fn, delay = 500) {
// timer 是在闭包中的
let timer = null
return function() {
clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, arguments)
}, delay)
}
}
export function throttle(fn, delay = 500) {
let timer = null
return function(e) {
if (timer) {
return
}
timer = setTimeout(() => {
fn.apply(this, arguments)
// fn(e)
timer = null
}, delay)
}
}
/**
* 深拷贝
* @param {} target
*/
export function deepClone(target) {
// 定义一个变量
let result
// 如果当前需要深拷贝的是一个对象的话
if (typeof target === 'object') {
// 如果是一个数组的话
if (Array.isArray(target)) {
result = [] // 将result赋值为一个数组,并且执行遍历
for (let i in target) {
// 递归克隆数组中的每一项
result.push(this.deepClone(target[i]))
}
// 判断如果当前的值是null的话;直接赋值为null
} else if (target === null) {
result = null
// 判断如果当前的值是一个RegExp对象的话,直接赋值
} else if (target.constructor === RegExp) {
result = target
} else {
// 否则是普通对象,直接for in循环,递归赋值对象的所有值
result = {}
for (let i in target) {
result[i] = this.deepClone(target[i])
}
}
// 如果不是对象的话,就是基本数据类型,那么直接赋值
} else {
result = target
}
// 返回最终结果
return result
}
export function fixed(num, decimal) {
num = num.toString()
let index = num.indexOf('.')
if (index !== -1) {
num = num.substring(0, decimal + index + 1)
} else {
num = num.substring(0)
}
return parseFloat(num).toFixed(decimal)
}
/**
* 四舍五入,保留指定小数位数,当原始数据不满足长度时,补 0
* @param number [Number | String] 原始数据,支持字符串和数值型
* @param i [Number] 保留的小数个数 >= 0
* @returns [Number] 转换后的数据
*/
export function transformDecimal(number, i) {
let decimalNum = null
// 先转换为数值型
let num = Number(number)
// 判断是否为数值型
if (!isNaN(num)) {
// 切分整数与小数
let arr = num.toString().split('.')
// 是小数且小数位大于保留个数
if (arr.length > 1 && arr[1].length > i) {
// 小数部分字符串
let decimal = arr[1].slice(i, i + 1)
// toFixed 有 bug,四舍六入五随机
// 当四舍五入的数为 5,给其 + 1
if (decimal === '5') {
// 这里可能会存在 0.1 ** 5 = 0.000010000000000000003 但不影响四舍五入
num += Math.pow(0.1, i + 1)
}
decimalNum = num.toFixed(i)
} else {
decimalNum = num
}
decimalNum = Number(decimalNum).toFixed(i)
}
return decimalNum
}
\ No newline at end of file
import Vue from 'vue'
import { Toast, Dialog } from 'vant'
/**
* 日期格式化
* let time = new Date().format('yyyy-MM-dd hh:mm:ss')
*/
Date.prototype.format = function (fmt) {
let o = {
'M+': this.getMonth() + 1, //月份
'd+': this.getDate(), //日
'h+': this.getHours(), //小时
'm+': this.getMinutes(), //分
's+': this.getSeconds(), //秒
//季度
'q+': Math.floor((this.getMonth() + 3) / 3),
S: this.getMilliseconds() //毫秒
}
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp(`(${k})`).test(fmt)) {
fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length))
}
}
return fmt
}
const iosTimeFormat = time => {
return time.replace(/\-/g, '/')
}
const throttle = (fn, gapTime) => {
if (gapTime == null || gapTime == undefined) {
gapTime = 1500
}
let _lastTime = null
return function () {
let _nowTime = +new Date()
if (_nowTime - _lastTime > gapTime || !_lastTime) {
fn.apply(this, arguments)
_lastTime = _nowTime
}
}
}
const debounce = (fn, delay = 500) => {
// timer 是在闭包中的
let timer = null
return function () {
clearTimeout(timer)
timer = setTimeout(() => {
fn.apply(this, arguments)
}, delay)
}
}
/**防止重复点击 */
const showLoading = (title = '加载中...') => {
Toast({
type: 'loading',
message: title,
forbidClick: true,
duration: 0
})
}
const hideLoading = () => {
Toast.clear()
}
/**num:要转换的数值,fixed:精确几位小数 */
const decimal = (num, fixed) => {
let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow
}
const showToast = (message = '', callBack) => {
hideLoading()
let params = {
message,
forbidClick: true,
duration: 1500
}
Toast(params)
if (callBack && typeof callBack == 'function') {
setTimeout(() => {
callBack()
}, 1500)
}
}
/**触摸样式 */
const touchstart = e => {
e.target.classList.add('btn-on-leave')
}
const touchend = e => {
e.target.classList.remove('btn-on-leave')
}
const setSessionId = val => {
window.localStorage.setItem('wx_scrm_session_id', val)
}
const getSessionId = () => {
return window.localStorage.getItem('wx_scrm_session_id')
}
const clearSessionId = () => {
window.localStorage.removeItem('wx_scrm_session_id')
}
const setAppId = val => {
window.localStorage.setItem('wx_scrm_app_id', val)
}
const getAppId = () => {
return window.localStorage.getItem('wx_scrm_app_id')
}
const setUserInfo = val => {
setLocalStorage('wx_scrm_user_info', val)
}
const getUserInfo = () => {
return getLocalStorage('wx_scrm_user_info')
}
const setLocalStorage = (key, item) => {
window.localStorage.setItem(key, JSON.stringify(item))
}
const getLocalStorage = key => {
return JSON.parse(window.localStorage.getItem(key))
}
const removeLocalStorage = key => {
window.localStorage.removeItem(key)
}
const dialog = (params = {}) => {
if (!params.confirmButtonColor) params.confirmButtonColor = '#FF7336'
return Dialog.confirm(params)
}
/**拨打电话 */
const makePhoneCall = phoneNumber => {
window.location.href = `tel://${phoneNumber}`
}
/**是否全面屏 */
const isFullSucreen = () => {
let result = false
const rate = window.screen.height / window.screen.width
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65 // 临界判断值
result = rate > limit
return result
}
const jumpChildrenPage = (to, params) => {
let { name } = window.vm._route
window.vm.$router.push({ name: `${name}.${to}`, params })
}
/**拷贝 */
const setClipboardData = data => {
wx.setClipboardData({
data,
success (res) {
Toast('复制成功')
}
})
}
/**接口请求时失败让用户刷新 */
const refreshPage = (message = '系统异常') => {
return Dialog.alert({
message,
theme: 'round-button',
confirmButtonText: '点击重试',
confirmButtonColor: '#FF7336'
})
}
const toTop = () => {
let bodySrcollTop = document.body.scrollTop
if (bodySrcollTop !== 0) {
document.body.scrollTop = 0
return
}
let docSrcollTop = document.documentElement.scrollTop
if (docSrcollTop !== 0) {
document.documentElement.scrollTop = 0
}
}
const getParams = () => {
return window.vm.$route.params
}
const getQuery = () => {
return window.vm.$route.query
}
const watchPageBack = () => {
return new Promise(resolve => {
if (window.$back) {
window.$back = false
resolve()
}
})
}
/**分转元 */
const centsToyuan = price => {
return decimal(price / 100, 2).toFixed(2)
}
/**设置cookie */
const setCookie = (c_name, value, expiredays = 365) => {
let exdate = new Date()
console.log(c_name, value)
exdate.setDate(exdate.getDate() + expiredays)
document.cookie = c_name + '=' + value +
((expiredays == null) ? '' : ';expires=' + exdate.toGMTString())
}
/**获取cookie */
const getCookie = c_name => {
if (document.cookie.length > 0) {
let c_start = document.cookie.indexOf(c_name + '=')
if (c_start != -1) {
c_start = c_start + c_name.length + 1
let c_end = document.cookie.indexOf(';', c_start)
if (c_end == -1) c_end = document.cookie.length
return unescape(document.cookie.substring(c_start, c_end))
}
}
return ''
}
const utils = {
removeLocalStorage,
setClipboardData,
jumpChildrenPage,
setLocalStorage,
getLocalStorage,
clearSessionId,
makePhoneCall,
isFullSucreen,
watchPageBack,
iosTimeFormat,
setSessionId,
getSessionId,
showLoading,
centsToyuan,
setUserInfo,
getUserInfo,
hideLoading,
refreshPage,
touchstart,
showToast,
getParams,
setCookie,
getCookie,
setAppId,
getAppId,
debounce,
getQuery,
touchend,
throttle,
decimal,
dialog,
toTop
}
Object.keys(utils).map(key => {
Vue.prototype[key] = utils[key]
})
export default utils
<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
<template>
<div>
<template v-if="timeFlag">
<div class="title">
{{detail.activityStatus == 1 ?'距离活动开始':'活动倒计时'}}
<div class="sprite-icon icon-title xy-center"></div>
</div>
<div :class="['time-box flex',{'not-started':detail.activityStatus == 1},{'finished':finished}]">
<template v-if="finished">{{finished}}</template>
<template v-else>
<template v-if="detail.activityStatus == 1">
{{new Date(iosTimeFormat(detail.startTime)).format('d')}}日开始活动,还差
</template>
<template v-if="activityTime.day">
<div class="time flex">
<span class="text-center flex">{{activityTime.day}}</span>
<div class="unit">天</div>
</div>
</template>
<template v-for="(i,index) in activityTime.dayList">
<div
class="time flex"
:key="index"
>
<span class="text-center flex">{{i.text}}</span>
<div class="unit">{{i.unit}}</div>
</div>
</template>
</template>
</div>
</template>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: 'CountDown',
props: {
detail: {
type: Object,
default: () => { }
},
updata: Number
},
watch: {
'updata': function (n) {
this.timeFlag = false
let { detail } = this
this.countDown([detail.startTime, detail.endTime])
}
},
data () {
return {
activityTime: {},
timeFlag: false,
finished: ''
}
},
mounted () {
},
methods: {
countDown (params) {
let {
activityStatus
} = this.detail
// activityStatus 1:未开始,2进行中,3已结束
const addZero = i => i < 10 ? `0${i}` : `${i}`
let [activityStartTime, activityEndTime] = params
const start = this.iosTimeFormat(activityStartTime)
const end = this.iosTimeFormat(activityEndTime)
if ((new Date().getTime() > new Date(end).getTime()) || activityStatus == 3) {
clearTimeout(this.time)
this.timeFlag = true
this.finished = '活动已结束'
if (activityStatus != 3) this.$emit('refresh')
return
}
if (new Date().getTime() >= new Date(start).getTime() && activityStatus != 2) {
this.$emit('refresh')
return
}
let starTime = new Date()
let endTime = new Date(activityStatus == 2 ? end : start)
let lefttime = parseInt((endTime.getTime() - starTime.getTime()) / 1000)
let d = parseInt(lefttime / (24 * 60 * 60))
let h = parseInt(lefttime / (60 * 60) % 24)
let m = parseInt(lefttime / 60 % 60)
let s = parseInt(lefttime % 60)
h = addZero(h)
m = addZero(m)
s = addZero(s)
let type = {
1: '距开始',
2: '距结束'
}[activityStatus]
if (this.time) clearTimeout(this.time)
this.time = setTimeout(() => {
let dayList = [{
text: h,
unit: '时'
}, {
text: m,
unit: '分'
}, {
text: s,
unit: '秒'
}]
let activityTime = {
dayList,
type
}
if (d > 0) activityTime.day = addZero(d)
this.activityTime = activityTime
this.timeFlag = true
this.countDown(params)
}, 1 * 1000)
}
}
}
</script>
<style scoped lang='scss'>
@import '@/assets/css/crowdfunding.scss';
.time-box {
height: 56px;
background: #fff5f3;
border-radius: 4px;
margin: 14px 0;
justify-content: center;
.time {
span {
height: 24px;
background: #fa2c18;
border-radius: 3px;
font-size: 16px;
font-weight: 600;
color: #ffffff;
padding: 0 4px;
}
.unit {
font-weight: 600;
font-size: 16px;
color: #fa2c18;
margin: 0 4px 0 2px;
}
}
}
.not-started {
font-size: 12px;
font-weight: 600;
color: #333333;
border: 1px dashed #e3e3e3;
background: #fff;
.time {
color: #333333;
span {
background: #fff5f3;
color: #f13c3d;
font-size: 14px;
}
.unit {
font-size: 12px;
color: #333333;
}
}
}
.finished {
background: #f0f0f0;
font-size: 18px;
font-weight: 600;
color: #999999;
}
</style>
\ No newline at end of file
<template>
<div class="group-list">
<template v-if="list.length">
<!-- :style="{'top':top}" -->
<div
class="move"
>
<template v-for="(i,index) in list">
<div
class="item flex"
:key="index"
>
<img :src="i.imageUrl">
<div class="text">{{i.name}}刚刚参加了活动</div>
</div>
</template>
</div>
</template>
</div>
</template>
<script type='text/ecmascript-6'>
let index = 0,
timer = null
export default {
name: 'MoveGroup',
props: ['groupInfo'],
watch: {
'groupInfo' (n) {
if (n && n.groupList && n.groupList.length) this.setList(n.groupList)
}
},
data () {
return {
list: [],
top: '0'
}
},
mounted () {
if (timer) clearInterval(timer)
},
methods: {
setList (list) {
if (list.length > 7) {
list.map((e, ind) => {
if (ind < 7) this.list.push(e)
})
// let t = setInterval(() => {
// index += 1
// if (index == 7) clearInterval(t)
// this.top = `${220 - 32 * index}px`
// }, 1e3)
// setTimeout(() => {
this.list.push(list[index])
this.move(list)
// }, 7e3)
} else this.list = list
},
move (list) {
timer = setInterval(() => {
if (index == list.length - 1) index = 0
else index += 1
// this.top = `${220 - 32 * (index)}px`
this.list.push(list[index])
this.list.shift()
}, 1e3)
}
}
}
</script>
<style scoped lang='scss'>
.group-list {
position: absolute;
left: 8px;
bottom: 52px;
width: 180px;
height: 220px;
overflow: hidden;
.move {
position: absolute;
left: 0;
top: 0;
transition: all 1s;
}
.item {
width: 160px;
height: 28px;
background: rgba(0, 0, 0, 0.5);
border-radius: 17px;
margin-bottom: 4px;
font-size: 12px;
font-weight: 500;
color: #ffffff;
&:nth-child(1) {
background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
.text {
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, #ffffff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
&:nth-child(7) {
background: linear-gradient(360deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.5) 100%);
.text {
background: linear-gradient(360deg, rgba(255, 255, 255, 0) 0%, #ffffff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
img {
margin: 0 3px;
width: 22px;
height: 22px;
border-radius: 100%;
overflow: hidden;
}
}
}
</style>
\ No newline at end of file
<template>
<div class="layout">
<div
class="to-top"
v-show="scrollY > 300"
@click="toTop"
>
<div class="sprite-icon icon-top"></div>
</div>
<div
class="kf"
@click="clickKF"
>
<div class="sprite-icon icon-kf"></div>
</div>
<div class="big-img">
<img :src="detail.activityBigImg">
<div
class="hot x-center flex"
v-if="groupInfo.groupQuantity"
>
<div class="sprite-icon icon-hot"></div>
{{groupInfo.groupQuantity}}人已参团
</div>
<div
class="music"
@click="musicOff = !musicOff"
>
<div :class="['sprite-icon',musicOff ?'icon-music-off':'icon-music']"></div>
<audio
:src="musicOff?'':detail.activityMusic"
autoplay
loop
></audio>
</div>
<move-group
:groupInfo="groupInfo"
class="group-list"
/>
</div>
<template v-if="detail.activityVideos && detail.activityVideos.length">
<div class="video">
<video
:src="detail.activityVideos[currentVideoIndex].activityVideo"
controls
webkit-playsinline
playsinline
loop
autoplay
></video>
</div>
<template v-if="detail.activityVideos.length > 1">
<div class="video-title">所有视频<span>({{detail.activityVideos.length}}个)</span></div>
<div class="video-box flex">
<template v-for="(i,index) in detail.activityVideos">
<div
class="item"
:key="index"
@click="currentVideoIndex = index"
>
<video :src="i.activityVideo"></video>
</div>
</template>
</div>
</template>
</template>
<div class="activity">
<div class="box">
<div class="title">
活动举办方
<div class="sprite-icon icon-title xy-center"></div>
</div>
<div class="address-box">
<div class="address-info">
<div class="name">
{{detail.sponsorName}}
</div>
<div class="text">{{detail.activityAddressDetailName}}</div>
<div class="time flex">
<div class="sprite-icon icon-time"></div>
活动时间:
{{detail.s_time}}-{{detail.e_time}}
</div>
</div>
<div
class="address-btn"
:key="distanceKey"
@click="openLocation"
>
<div class="sprite-icon icon-address"></div>
<template v-if="detail.distance">
{{detail.distance }}km
</template>
</div>
</div>
</div>
<div class="box">
<count-down
:detail="detail"
:updata="updata"
@refresh="refresh"
/>
<div class="group-title">
<span>{{groupInfo.groupQuantity}}</span>人已参团
<div class="view">浏览{{groupInfo.viewAmount}}</div>
</div>
<div class="group-box">
<template v-for="(i,index) in groupInfo.groupList">
<div
class="item"
:key="index"
>
<img :src="i.imageUrl" />
<div class="name">{{i.name}}</div>
</div>
</template>
</div>
</div>
<div class="box">
<div class="title">
活动进度
<div class="sprite-icon icon-title xy-center"></div>
</div>
<div class="progress-bar">
<div
class="bar sprite-icon icon-flash"
:style="{'left':`${groupInfo.progress > 100 ? 100 : groupInfo.progress}%`}"
></div>
<div class="progress">
<div
:class="['line flex',{'line-padding':groupInfo.progress}]"
:style="{'width':`${groupInfo.progress > 100 ? 100 : groupInfo.progress}%`}"
>{{groupInfo.progress ? `${groupInfo.progress}%`: ''}}</div>
</div>
</div>
<div class="group-info flex">
<div class="item">最低折扣<br>需{{groupInfo.fictitiousLadderQuantity}}人</div>
<div class="item">已参与<br>{{groupInfo.groupQuantity}}人</div>
<div>众筹<br>成功</div>
</div>
</div>
</div>
<template v-if="detail.activityDetail">
<div
class="activity-info"
v-html="decodeURIComponent(detail.activityDetail)"
>
</div>
</template>
<action :detail="detail"></action>
<kf-modal
v-model="showKf"
:detail="detail"
/>
</div>
</template>
<script type='text/ecmascript-6'>
import { shopmallApi, wxConfig, mapApi, bigdatautilApi } from '@/api'
import MoveGroup from './components/MoveGroup.vue'
import CountDown from './components/CountDown.vue'
export default {
components: { MoveGroup, CountDown },
name: 'index',
data () {
return {
id: null,
detail: {},
groupInfo: {},
currentVideoIndex: 0,
musicOff: false,
scrollY: 0,
updata: Date.now(),
distanceKey: Date.now(),
noAuthAddress: false,
showKf: false
}
},
mounted () {
wxConfig.init(['getLocation', 'openLocation', 'updateAppMessageShareData']).then(() => {
wxConfig.ready(() => {
this.getActivityDetail()
})
})
let _this = this
window.addEventListener('scroll', _this.debounce(() => {
_this.scrollY = window.scrollY
}, 1e3 / 2))
},
methods: {
refresh () {
this.getActivityDetail()
},
getActivityDetail () {
let { id } = this.getQuery()
let params = this.getLocalStorage('wx_scrm_link_params')
let userInfo = this.getUserInfo()
bigdatautilApi.reportTrack(id)
if (!id) id = params.id
this.showLoading()
shopmallApi.getActivityDetail(id).then(data => {
console.log(JSON.parse(JSON.stringify(data)))
data.s_time = new Date(this.iosTimeFormat(data.startTime)).format('yyyy年M月d日')
data.e_time = new Date(this.iosTimeFormat(data.endTime)).format('yyyy年M月d日')
document.title = data.activityName
this.hideLoading()
this.detail = data
this.id = id
this.getActivityGroup()
let [redirectUrl] = window.location.href.split('?')
wxConfig.updateAppMessageShareData({
title: data.activityName,
desc: `限时大型众筹,活动时间${data.s_time}-${data.e_time}`,
link: `${redirectUrl}?id=${id}&staffUuid=${params.staffUuid}&userPhone=${userInfo.phone}`,
imgUrl: data.posterImg
})
wxConfig.getLocation().then(res => {
console.log(res)
mapApi.calculateDistance([res.latitude, res.longitude], [data.activityAddressLat, data.activityAddressLng]).then(({ elements: [res] }) => {
this.detail.distance = Number((res.distance / 1000)).toFixed(2)
this.distanceKey = Date.now()
console.log(this.detail)
})
})
})
},
getActivityGroup () {
shopmallApi.getActivityGroup(this.id).then(data => {
// console.log(JSON.parse(JSON.stringify(data)))
data.progress = this.decimal((data.groupQuantity / data.fictitiousLadderQuantity) * 100, 2)
this.groupInfo = data
this.updata = Date.now()
})
},
toTop () {
document.body.scrollTop = 0
},
openLocation () {
let { sponsorName, activityAddressDetailName, activityAddressLat, activityAddressLng } = this.detail
wxConfig.openLocation({
latitude: activityAddressLat,
longitude: activityAddressLng,
name: sponsorName,
address: activityAddressDetailName
})
},
clickKF () {
// 活动客服标志:1 同步在线客服;2 单独设置
let { customerServiceFlag } = this.detail
this.showKf = true
// if (customerServiceFlag == 2) this.showKf = true
}
}
}
</script>
<style scoped lang='scss'>
@import '@/assets/css/crowdfunding.scss';
</style>
\ No newline at end of file
<template>
<div class="layout flex">
<div class="sprite-icon icon-success"></div>
<div class="title">您已参团成功!</div>
<div class="info">您可以点击下面图标进入广汇车生活小程序,到店凭核销码核销订单并支付尾款,更有会员套餐等多重福利可享!</div>
<div class="miniprogram flex">
<div class="icon text-center">
<img src="@/assets/images/logo.png" />
</div>
广汇车生活小程序
<wx-open-launch-weapp
class="mini"
path="pages/tab/index/index.html"
username="gh_21f69fe893fc"
:env-version="envVersion"
>
<script type="text/wxtag-template">
<div class="mini-btn">点击跳转</div>
</script>
</wx-open-launch-weapp>
</div>
</div>
</template>
<script type='text/ecmascript-6'>
export default {
name: '',
data () {
return {
envVersion: 'release'
}
},
mounted () {
const { envVersion } = window.$fetchConfig
this.envVersion = envVersion
},
methods: {
}
}
</script>
<style scoped lang='scss'>
.layout {
flex-direction: column;
padding: 56px 48px 0;
font-size: 14px;
color: #656566;
.title {
font-size: 16px;
font-weight: 500;
color: #2d2d2e;
padding: 42px 0 10px;
}
.info {
margin-bottom: 150px;
}
.miniprogram {
flex-direction: column;
font-weight: 500;
position: relative;
overflow: hidden;
width: 115px;
height: 100px;
.mini {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 2;
opacity: 0;
&-btn {
width: 100%;
height: 100%;
}
}
.icon {
width: 70px;
height: 70px;
border: 1px solid #dddddd;
border-radius: 100%;
overflow: hidden;
box-sizing: border-box;
margin-bottom: 4px;
}
}
}
</style>
\ No newline at end of file
'use strict'
const path = require('path')
const defaultSettings = require('./src/config/conf.js')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const resolve = dir => path.join(__dirname, dir)
// page title
const name = defaultSettings.title || 'vue mobile template'
// 生产环境,测试和正式
const IS_PROD = ['production', 'prod'].includes(process.env.NODE_ENV)
// externals
// const externals = {
// vue: 'Vue',
// 'vue-router': 'VueRouter',
// vuex: 'Vuex',
// vant: 'vant',
// axios: 'axios'
// }
// CDN外链,会插入到index.html中
// const cdn = {
// // 开发环境
// dev: {
// css: [],
// js: []
// },
// // 生产环境
// build: {
// css: ['https://cdn.jsdelivr.net/npm/vant@2.4.7/lib/index.css'],
// 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/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/vant@2.4.7/lib/index.min.js'
// ]
// }
// }
/**
* 雪碧图插件
*/
const SpritesmithPlugin = require('webpack-spritesmith')
const spritesmithFunction = data => {
let { spritesheet, sprites } = data
let 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 => {
let { 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;}`
}).join('\n')
return `${shared}\n${perSprite}`
}
module.exports = {
publicPath: IS_PROD ? './' : '/dj-scrm-wx-work-main-lwk/', // 本地调试时需登录时使用
// publicPath: './',
// publicPath: '/dj-scrm-wx-work-attachment-activity/', // 署应用包时的基本 URL。 vue-router history模式使用
outputDir: 'dist', // 生产环境构建文件的目录
assetsDir: 'static', // outputDir的静态资源(js、css、img、fonts)目录
lintOnSave: !IS_PROD,
productionSourceMap: false, // 如果不需要生产环境的 source map,可以将其设置为 false 以加速生产环境构建。
devServer: {
disableHostCheck: true,
port: 9527, // 端口
open: false, // 启动后打开浏览器
public:'http://scrm.dev.glsx.com.cn/dj-scrm-wx-work-main/#/',
overlay: {
// 当出现编译器错误或警告时,在浏览器中显示全屏覆盖层
warnings: false,
errors: true
}
// proxy: {
// //配置跨域
// '/api': {
// target: "https://test.xxx.com",
// // ws:true,
// changOrigin:true,
// pathRewrite:{
// '^/api':'/'
// }
// }
// }
},
css: {
extract: IS_PROD, // 是否将组件中的 CSS 提取至一个独立的 CSS 文件中 (而不是动态注入到 JavaScript 中的 inline 代码)。
sourceMap: false,
loaderOptions: {
scss: {
// 向全局sass样式传入共享的全局变量, $src可以配置图片cdn前缀
// 详情: https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders
prependData: `
$cdn: "${defaultSettings.cdn}";
`
}
}
},
configureWebpack: config => {
config.name = name
config.resolve.modules = ['node_modules', './src/assets/spritesmith']
const Plugins = [
new SpritesmithPlugin({
// 引入图片文件夹
src: {
cwd: path.resolve(__dirname, './src/assets/spritesmith'),
glob: ['*.png', '*.jpg']
},
// 生成图片的路径
target: {
image: path.resolve(__dirname, './src/assets/images/sprite.png'),
// 生成SCSS
css: [
[path.resolve(__dirname, './src/assets/css/sprite.scss'), {
format: 'function_based_template'
}]
]
},
customTemplates: {
'function_based_template': spritesmithFunction,
},
//background引用路径
apiOptions: {
cssImageRef: '../images/sprite.png'
},
// 每个图片间距
spritesmithOptions: {
padding: 20
}
})
]
config.plugins = [...config.plugins, ...Plugins]
// 为生产环境修改配置...
// if (IS_PROD) {
// // externals
// config.externals = externals
// }
},
chainWebpack: config => {
config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test
// 别名 alias
config.resolve.alias
.set('@', resolve('src'))
.set('assets', resolve('src/assets'))
.set('api', resolve('src/api'))
.set('views', resolve('src/views'))
.set('components', resolve('src/components'))
.set('plugins', resolve('src/components'))
.set('utils', resolve('src/utils'))
/**
* 添加CDN参数到htmlWebpackPlugin配置中
*/
// config.plugin('html').tap(args => {
// if (IS_PROD) {
// args[0].cdn = cdn.build
// } else {
// args[0].cdn = cdn.dev
// }
// return args
// })
/**
* 设置保留空格
*/
config.module
.rule('vue')
.use('vue-loader')
.loader('vue-loader')
.tap(options => {
options.compilerOptions.preserveWhitespace = true
return options
})
.end()
/**
* 打包分析
*/
if (IS_PROD) {
config.plugin('webpack-report').use(BundleAnalyzerPlugin, [{
analyzerMode: 'static'
}])
}
config
// https://webpack.js.org/configuration/devtool/#development
.when(!IS_PROD, config => config.devtool('cheap-source-map'))
config.when(IS_PROD, config => {
config
.plugin('ScriptExtHtmlWebpackPlugin')
.after('html')
.use('script-ext-html-webpack-plugin', [{
// 将 runtime 作为内联引入不单独存在
inline: /runtime\..*\.js$/
}])
.end()
config.optimization.splitChunks({
chunks: 'all',
cacheGroups: {
// cacheGroups 下可以可以配置多个组,每个组根据test设置条件,符合test条件的模块
commons: {
name: 'chunk-commons',
test: resolve('src/components'),
minChunks: 3, // 被至少用三次以上打包分离
priority: 5, // 优先级
reuseExistingChunk: true // 表示是否使用已有的 chunk,如果为 true 则表示如果当前的 chunk 包含的模块已经被抽取出去了,那么将不会重新生成新的。
},
node_vendors: {
name: 'chunk-libs',
chunks: 'initial', // 只打包初始时依赖的第三方
test: /[\\/]node_modules[\\/]/,
priority: 10
},
vantUI: {
name: 'chunk-vantUI', // 单独将 vantUI 拆包
priority: 20, // 数字大权重到,满足多个 cacheGroups 的条件时候分到权重高的
test: /[\\/]node_modules[\\/]_?vant(.*)/
}
}
})
config.optimization.runtimeChunk('single')
})
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!