You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
672 lines
17 KiB
672 lines
17 KiB
import Vue from 'vue'
|
|
import Vuex from 'vuex'
|
|
Vue.use(Vuex)
|
|
|
|
import Http from '../common/js/http.js'
|
|
import colorList from '../common/js/style_color.js'
|
|
|
|
const store = new Vuex.Store({
|
|
state: {
|
|
navbarBgColor: 'transparent',
|
|
tabList: [{
|
|
text: '首页',
|
|
pagePath: 'page_salesman_index/index/index'
|
|
},
|
|
{
|
|
text: '数据报表',
|
|
pagePath: 'page_salesman_reportForm/index/index'
|
|
},
|
|
{
|
|
text: '订单',
|
|
pagePath: 'page_salesman_order/index/index'
|
|
},
|
|
{
|
|
text: '客户',
|
|
pagePath: 'page_salesman_customer/index/index'
|
|
},
|
|
],
|
|
// tabBarList: '',
|
|
// 给默认值
|
|
tabBarList: {
|
|
"type": 1,
|
|
"theme": "default",
|
|
"backgroundColor": "#FFFFFF",
|
|
"textColor": "#333333",
|
|
"textHoverColor": "#19C650",
|
|
"bulge": true,
|
|
"list": [{
|
|
"iconPath": "icondiy icon-system-shouyeweixuanzhongbeifen",
|
|
"selectedIconPath": "icondiy icon-system-shouyexuanzhongbeifen2",
|
|
"text": "首页",
|
|
"link": {
|
|
"name": "INDEX",
|
|
"title": "主页",
|
|
"wap_url": "/pages/index/index",
|
|
"parent": "MALL_LINK"
|
|
},
|
|
"id": "1l239rtm1og00",
|
|
"imgWidth": "40",
|
|
"imgHeight": "40",
|
|
"iconClass": "icon-system-home",
|
|
"icon_type": "icon",
|
|
"selected_icon_type": "icon",
|
|
"style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#999999"
|
|
],
|
|
"iconColorDeg": 0
|
|
},
|
|
"selected_style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#19C650"
|
|
],
|
|
"iconColorDeg": 0
|
|
}
|
|
},
|
|
{
|
|
"iconPath": "icondiy icon-system-fenleiweixuanzhongbeifen2",
|
|
"selectedIconPath": "icondiy icon-system-fenleixuanzhongbeifen1",
|
|
"text": "分类",
|
|
"link": {
|
|
"name": "SHOP_CATEGORY",
|
|
"title": "商品分类",
|
|
"wap_url": "/pages/goods/category",
|
|
"parent": "MALL_LINK"
|
|
},
|
|
"imgWidth": "40",
|
|
"imgHeight": "40",
|
|
"id": "1deifk7k5ytc0",
|
|
"iconClass": "icon-system-category",
|
|
"icon_type": "icon",
|
|
"selected_icon_type": "icon",
|
|
"style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#999999"
|
|
],
|
|
"iconColorDeg": 0
|
|
},
|
|
"selected_style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#19C650"
|
|
],
|
|
"iconColorDeg": 0
|
|
}
|
|
},
|
|
{
|
|
"iconPath": "icondiy icon-system-cart",
|
|
"selectedIconPath": "icondiy icon-system-cart-selected",
|
|
"text": "购物车",
|
|
"link": {
|
|
"name": "SHOPPING_TROLLEY",
|
|
"title": "购物车",
|
|
"wap_url": "/pages/goods/cart",
|
|
"parent": "MALL_LINK"
|
|
},
|
|
"imgWidth": "40",
|
|
"imgHeight": "40",
|
|
"id": "1jthptrqm4800",
|
|
"iconClass": "icon-system-cart",
|
|
"icon_type": "icon",
|
|
"selected_icon_type": "icon",
|
|
"style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#999999"
|
|
],
|
|
"iconColorDeg": 0
|
|
},
|
|
"selected_style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#19C650"
|
|
],
|
|
"iconColorDeg": 0
|
|
}
|
|
},
|
|
{
|
|
"iconPath": "icondiy icon-system-nurse-line",
|
|
"selectedIconPath": "icondiy icon-system-nurse-fill",
|
|
"text": "我的",
|
|
"link": {
|
|
"name": "MEMBER_CENTER",
|
|
"title": "会员中心",
|
|
"wap_url": "/pages/member/index",
|
|
"parent": "MALL_LINK"
|
|
},
|
|
"imgWidth": "40",
|
|
"imgHeight": "40",
|
|
"id": "1we7vfq7bsbk0",
|
|
"iconClass": "icon-system-my",
|
|
"icon_type": "icon",
|
|
"selected_icon_type": "icon",
|
|
"style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#999999"
|
|
],
|
|
"iconColorDeg": 0
|
|
},
|
|
"selected_style": {
|
|
"fontSize": 100,
|
|
"iconBgColor": [],
|
|
"iconBgColorDeg": 0,
|
|
"iconBgImg": "",
|
|
"bgRadius": 0,
|
|
"iconColor": [
|
|
"#19C650"
|
|
],
|
|
"iconColorDeg": 0
|
|
}
|
|
}
|
|
],
|
|
"imgType": 2,
|
|
"iconColor": "#333333",
|
|
"iconHoverColor": "#FF4D4D"
|
|
},
|
|
siteState: 1,
|
|
themeStyle: '',
|
|
addonIsExist: {
|
|
bundling: 0,
|
|
coupon: 0,
|
|
discount: 0,
|
|
fenxiao: 0,
|
|
gift: 0,
|
|
groupbuy: 0,
|
|
manjian: 0,
|
|
memberconsume: 0,
|
|
memberrecharge: 0,
|
|
memberregister: 0,
|
|
membersignin: 0,
|
|
memberwithdraw: 0,
|
|
memberrecommend: 0,
|
|
pintuan: 0,
|
|
pointexchange: 0,
|
|
seckill: 0,
|
|
store: 0,
|
|
topic: 0,
|
|
bargain: 0,
|
|
membercancel: 0,
|
|
servicer: 0,
|
|
supermember: 0,
|
|
giftcard: 0,
|
|
divideticket: 0,
|
|
scenefestival: 0,
|
|
birthdaygift: 0,
|
|
pinfan: 0
|
|
},
|
|
sourceMember: 0, // 来源会员
|
|
authInfo: {}, // 授权信息
|
|
token: null,
|
|
flRefresh: 0,
|
|
location: null, // 定位信息
|
|
defaultImg: {
|
|
goods: '',
|
|
head: '',
|
|
store: ''
|
|
},
|
|
cartNumber: 0,
|
|
cartList: {},
|
|
cartMoney: 0,
|
|
siteInfo: null,
|
|
cartChange: 0,
|
|
userInfo: null,
|
|
|
|
// 授权弹窗目的通知
|
|
WRITE_EXTERNAL_STORAGE: false,
|
|
READ_EXTERNAL_STORAGE: false,
|
|
CALL_PHONE: false,
|
|
/* #ifdef APP-PLUS */
|
|
isIos: plus.os.name == "iOS",
|
|
/* #endif */
|
|
mapping: {
|
|
'WRITE_EXTERNAL_STORAGE': {
|
|
title: "存储空间/照片权限说明",
|
|
content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布评论/分享、下载、与客服沟通等场景中读取和写入相册和文件内容。",
|
|
methods: 'SET_WRITE_EXTERNAL_STORAGE'
|
|
},
|
|
'READ_EXTERNAL_STORAGE': {
|
|
title: "存储空间/照片权限说明",
|
|
content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布评论/分享、下载、与客服沟通等场景中读取和写入相册和文件内容。",
|
|
methods: 'SET_READ_EXTERNAL_STORAGE'
|
|
},
|
|
'CALL_PHONE': {
|
|
title: "拨打/管理电话权限申请说明",
|
|
content: "便于您使用该功能联系买家、售后或者客服、业务经理与联系等场景下使用",
|
|
methods: 'SET_CALL_PHONE'
|
|
},
|
|
'CAMERA': {
|
|
title: "申请相机权限说明",
|
|
content: "便于您使用该功能上传您的照片/图片/视频及用于更换头像、发布评论/分享、下载、与客服沟通等场景中拍摄上传图片内容。",
|
|
methods: 'SET_CAMERA'
|
|
},
|
|
}
|
|
|
|
|
|
|
|
},
|
|
mutations: {
|
|
SET_userInfo: (state, userInfo) => {
|
|
state.userInfo = userInfo
|
|
},
|
|
setSiteState(state, siteStateVal) {
|
|
state.siteState = siteStateVal;
|
|
},
|
|
setCartNumber(state, cartNumber) {
|
|
state.cartNumber = cartNumber
|
|
},
|
|
setThemeStyle(state, value) {
|
|
state.themeStyle = value
|
|
|
|
uni.setStorageSync('theme_style', value);
|
|
},
|
|
setTabBarList(state, value) {
|
|
value.list = value.list.filter(item => item.text !=='视频')
|
|
state.tabBarList = value
|
|
uni.setStorageSync('bottomNav', value);
|
|
},
|
|
setAddonIsExist(state, value) {
|
|
state.addonIsExist = value;
|
|
uni.setStorageSync('addon_is_exist', value);
|
|
},
|
|
setToken(state, value) {
|
|
state.token = value;
|
|
},
|
|
setAuthinfo(state, value) {
|
|
state.authInfo = value;
|
|
},
|
|
setSourceMember(state, value) {
|
|
state.sourceMember = value;
|
|
},
|
|
setflRefresh(state, flRefreshVal) {
|
|
state.flRefresh = flRefreshVal;
|
|
},
|
|
setLocation(state, value) {
|
|
state.location = value;
|
|
},
|
|
setDefaultImg(state, value) {
|
|
uni.setStorageSync('default_img', value)
|
|
state.defaultImg = value;
|
|
},
|
|
setCartList(state, value) {
|
|
state.cartList = value;
|
|
},
|
|
setCartMoney(state, value) {
|
|
state.cartMoney = value;
|
|
},
|
|
setSiteInfo(state, value) {
|
|
state.siteInfo = value;
|
|
uni.setStorageSync('siteInfo', value)
|
|
},
|
|
setCartChange(state) {
|
|
state.cartChange += 1;
|
|
},
|
|
SET_WRITE_EXTERNAL_STORAGE(state, val) {
|
|
state.WRITE_EXTERNAL_STORAGE = val
|
|
},
|
|
SET_CALL_PHONE(state, val) {
|
|
state.CALL_PHONE = val
|
|
},
|
|
SET_READ_EXTERNAL_STORAGE(state, val) {
|
|
state.READ_EXTERNAL_STORAGE = val
|
|
}
|
|
},
|
|
getters: {
|
|
getSiteInfo(state) {
|
|
return state.siteInfo || {}
|
|
},
|
|
userInfo(state) {
|
|
return state.userInfo || {}
|
|
},
|
|
navbarBgColor(state) {
|
|
return state.navbarBgColor || ''
|
|
},
|
|
cartNumber(state) {
|
|
return state.cartNumber || 0
|
|
}
|
|
},
|
|
actions: {
|
|
getUserInfo({
|
|
commit,
|
|
state
|
|
}) {
|
|
return new Promise((resolve, reject) => {
|
|
let user_type = uni.getStorageSync("user_type"); // 1业务员端 2客户端
|
|
if (user_type == 2) {
|
|
Http.sendRequest({
|
|
url: '/api/member/info',
|
|
success: res => {
|
|
uni.setStorageSync('userInfo', res.data);
|
|
commit('SET_userInfo', res.data)
|
|
resolve(res.data)
|
|
}
|
|
})
|
|
} else if (user_type == 1) {
|
|
Http.sendRequest({
|
|
url: '/api/salasman/info',
|
|
success: res => {
|
|
uni.setStorageSync('userInfo', res.data);
|
|
commit('SET_userInfo', res.data)
|
|
resolve(res.data)
|
|
}
|
|
})
|
|
// 一类二类业务员部分权限检测
|
|
Http.sendRequest({
|
|
url: '/api/salasman/checkCurAuthinfo',
|
|
success: res => {
|
|
uni.setStorageSync('salesmanAuth', res.data);
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
})
|
|
},
|
|
|
|
init() {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
Http.sendRequest({
|
|
url: '/api/config/init',
|
|
success: res => {
|
|
var data = res.data;
|
|
if (data) {
|
|
|
|
let isActiveTheme = uni.getStorageSync('activeTheme')
|
|
if (isActiveTheme) {
|
|
colorList[data.style_theme.name].bg_color = isActiveTheme;
|
|
colorList[data.style_theme.name].bg_color_shallow =
|
|
isActiveTheme;
|
|
colorList[data.style_theme.name].main_color = isActiveTheme;
|
|
colorList[data.style_theme.name].promotion_color =
|
|
isActiveTheme;
|
|
colorList[data.style_theme.name].goods_detail
|
|
.goods_btn_color = isActiveTheme;
|
|
colorList[data.style_theme.name].goods_detail
|
|
.promotion_tag = isActiveTheme;
|
|
data.diy_bottom_nav.textHoverColor = isActiveTheme;
|
|
data.diy_bottom_nav.list.forEach(item => {
|
|
item.selected_style.iconColor[0] = isActiveTheme
|
|
})
|
|
}
|
|
|
|
this.commit('setCartNumber', data.cart_count);
|
|
|
|
this.commit('setThemeStyle', colorList[data.style_theme.name]);
|
|
|
|
// 底部导航
|
|
this.commit('setTabBarList', data.diy_bottom_nav);
|
|
|
|
this.commit('setAddonIsExist', data.addon_is_exist);
|
|
|
|
this.commit('setDefaultImg', data.default_img);
|
|
|
|
this.commit('setSiteInfo', data.site_info);
|
|
|
|
uni.setStorageSync('copyright', data.copyright);
|
|
|
|
resolve(data);
|
|
}
|
|
}
|
|
});
|
|
})
|
|
},
|
|
clearCartNumber() {
|
|
this.commit('setCartNumber', 0);
|
|
this.commit('setCartList', {});
|
|
this.commit('setCartMoney', 0);
|
|
},
|
|
//查询购物车数量
|
|
getCartNumber() {
|
|
if (uni.getStorageSync("token")) {
|
|
Http.sendRequest({
|
|
url: '/api/cart/lists',
|
|
success: res => {
|
|
if (res.code == 0) {
|
|
let cartList = {},
|
|
count = 0,
|
|
money = 0;
|
|
res.data.forEach(item => {
|
|
cartList['sku_' + item.sku_id] = item;
|
|
count += item.num;
|
|
money += item.total_money;
|
|
})
|
|
this.commit('setCartList', cartList);
|
|
this.commit('setCartNumber', count);
|
|
this.commit('setCartMoney', money);
|
|
uni.$emit('syncCartList')
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
this.commit('setCartNumber', 0);
|
|
this.commit('setCartList', {});
|
|
this.commit('setCartMoney', 0);
|
|
uni.$emit('syncCartList')
|
|
}
|
|
},
|
|
async requestPermissions({
|
|
state,
|
|
dispatch,
|
|
commit
|
|
}, permissionID) {
|
|
try {
|
|
if (!state[permissionID] && !state.isIos) {
|
|
var viewObj = await dispatch('nativeObjView', permissionID);
|
|
viewObj.show();
|
|
}
|
|
console.log('android.permission.' + permissionID, '当前手机权限');
|
|
return new Promise(async (resolve, reject) => {
|
|
//苹果不需要这个
|
|
if (state.isIos) {
|
|
resolve(1);
|
|
return
|
|
}
|
|
// Android权限查询
|
|
function requestAndroidPermission(permissionID_) {
|
|
return new Promise((resolve, reject) => {
|
|
plus.android.requestPermissions(
|
|
[
|
|
permissionID_
|
|
], // 理论上支持多个权限同时查询,但实际上本函数封装只处理了一个权限的情况。有需要的可自行扩展封装
|
|
function(resultObj) {
|
|
var result = 0;
|
|
for (var i = 0; i < resultObj.granted
|
|
.length; i++) {
|
|
var grantedPermission = resultObj.granted[
|
|
i];
|
|
console.log('已获取的权限:' + grantedPermission);
|
|
result = 1
|
|
}
|
|
for (var i = 0; i < resultObj.deniedPresent
|
|
.length; i++) {
|
|
var deniedPresentPermission = resultObj
|
|
.deniedPresent[
|
|
i];
|
|
console.log('拒绝本次申请的权限:' +
|
|
deniedPresentPermission);
|
|
result = 0
|
|
}
|
|
for (var i = 0; i < resultObj.deniedAlways
|
|
.length; i++) {
|
|
var deniedAlwaysPermission = resultObj
|
|
.deniedAlways[
|
|
i];
|
|
console.log('永久拒绝申请的权限:' +
|
|
deniedAlwaysPermission);
|
|
result = -1
|
|
}
|
|
resolve(result);
|
|
},
|
|
function(error) {
|
|
console.log('申请权限错误:' + error.code + " = " +
|
|
error
|
|
.message);
|
|
resolve({
|
|
code: error.code,
|
|
message: error.message
|
|
});
|
|
}
|
|
);
|
|
});
|
|
}
|
|
|
|
const result = await requestAndroidPermission(
|
|
'android.permission.' + permissionID
|
|
);
|
|
if (result === 1) {
|
|
//'已获得授权'
|
|
commit(state.mapping[permissionID].methods, true)
|
|
} else if (result === 0) {
|
|
//'未获得授权'
|
|
commit(state.mapping[permissionID].methods, false)
|
|
} else {
|
|
commit(state.mapping[permissionID].methods, true)
|
|
uni.showModal({
|
|
title: '提示',
|
|
content: '操作权限已被拒绝,请手动前往设置',
|
|
confirmText: "立即设置",
|
|
success: (res) => {
|
|
if (res.confirm) {
|
|
dispatch('gotoAppPermissionSetting')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
if (viewObj) viewObj.close()
|
|
resolve(result);
|
|
});
|
|
} catch (error) {
|
|
console.log(error);
|
|
reject(error);
|
|
}
|
|
},
|
|
//提示框
|
|
nativeObjView({
|
|
state
|
|
}, permissionID) {
|
|
const systemInfo = uni.getSystemInfoSync();
|
|
const statusBarHeight = systemInfo.statusBarHeight;
|
|
const navigationBarHeight = systemInfo.platform === 'android' ? 48 :
|
|
44; // Set the navigation bar height based on the platform
|
|
const totalHeight = statusBarHeight + navigationBarHeight;
|
|
let view = new plus.nativeObj.View('per-modal', {
|
|
top: '0px',
|
|
left: '0px',
|
|
width: '100%',
|
|
backgroundColor: '#444',
|
|
//opacity: .5;
|
|
})
|
|
view.drawRect({
|
|
color: '#fff',
|
|
radius: '5px'
|
|
}, {
|
|
top: totalHeight + 'px',
|
|
left: '5%',
|
|
width: '90%',
|
|
height: "100px",
|
|
})
|
|
view.drawText(state.mapping[permissionID].title, {
|
|
top: totalHeight + 5 + 'px',
|
|
left: "8%",
|
|
height: "30px"
|
|
}, {
|
|
align: "left",
|
|
color: "#000",
|
|
}, {
|
|
onClick: function(e) {
|
|
console.log(e);
|
|
}
|
|
})
|
|
view.drawText(state.mapping[permissionID].content, {
|
|
top: totalHeight + 35 + 'px',
|
|
height: "60px",
|
|
left: "8%",
|
|
width: "84%"
|
|
}, {
|
|
whiteSpace: 'normal',
|
|
size: "14px",
|
|
align: "left",
|
|
color: "#656563"
|
|
})
|
|
|
|
function show() {
|
|
view = plus.nativeObj.View.getViewById('per-modal');
|
|
view.show()
|
|
view = null //展示的时候也得清空,不然影响下次的关闭,不知道为啥
|
|
}
|
|
|
|
function close() {
|
|
view = plus.nativeObj.View.getViewById('per-modal');
|
|
view.close();
|
|
view = null
|
|
}
|
|
return {
|
|
show,
|
|
close
|
|
}
|
|
},
|
|
|
|
// 跳转到**应用**的权限页面
|
|
gotoAppPermissionSetting({
|
|
state
|
|
}) {
|
|
if (state.isIos) {
|
|
var UIApplication = plus.ios.import("UIApplication");
|
|
var application2 = UIApplication.sharedApplication();
|
|
var NSURL2 = plus.ios.import("NSURL");
|
|
// var setting2 = NSURL2.URLWithString("prefs:root=LOCATION_SERVICES");
|
|
var setting2 = NSURL2.URLWithString("app-settings:");
|
|
application2.openURL(setting2);
|
|
|
|
plus.ios.deleteObject(setting2);
|
|
plus.ios.deleteObject(NSURL2);
|
|
plus.ios.deleteObject(application2);
|
|
} else {
|
|
// console.log(plus.device.vendor);
|
|
var Intent = plus.android.importClass("android.content.Intent");
|
|
var Settings = plus.android.importClass("android.provider.Settings");
|
|
var Uri = plus.android.importClass("android.net.Uri");
|
|
var mainActivity = plus.android.runtimeMainActivity();
|
|
var intent = new Intent();
|
|
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
|
|
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
|
|
intent.setData(uri);
|
|
mainActivity.startActivity(intent);
|
|
}
|
|
}
|
|
|
|
}
|
|
})
|
|
export default store
|