新增营销系统、分销系统、会员功能、门店、提现功能
This commit is contained in:
19
components/canvasShow/config/api.js
Normal file
19
components/canvasShow/config/api.js
Normal file
@ -0,0 +1,19 @@
|
||||
// 导入api接口模块
|
||||
import { VUE_APP_API_URL } from '@/config'
|
||||
// 获取当前环境变量 true => 生产环境 false => 开发环境
|
||||
// const BASEURL = process.env.VUE_APP_DOMAIN_PREFIX
|
||||
const BASEURL = VUE_APP_API_URL
|
||||
// const BASEURL = (process.env.NODE_ENV === 'production') ? 'http://127.0.0.1:9007' : 'http://127.0.0.1:9007'
|
||||
|
||||
|
||||
export const api = {
|
||||
// 画布模块
|
||||
getCanvas: BASEURL + '/shop/canvas/canvas-json', // 读取画布
|
||||
getProducts: BASEURL + '/product/canvas/page', // 选择商品查询
|
||||
getCoupons: BASEURL + '/product/coupon/canvas-list', // 优惠券查询
|
||||
takeCoupon: BASEURL + '/product/coupon/relation/receive/', // 领取优惠券
|
||||
getActivityProduct: `${BASEURL}/product/campaign/product-page`, // 获取活动商品
|
||||
getActivity: `${BASEURL}/product/campaign/get`, // 获取单个活动
|
||||
|
||||
}
|
||||
export default api
|
24
components/canvasShow/config/config.js
Normal file
24
components/canvasShow/config/config.js
Normal file
@ -0,0 +1,24 @@
|
||||
// 画布配置
|
||||
// import Cookies from 'js-cookie'
|
||||
|
||||
const config = {
|
||||
terminal: 4, // 画布设备 1 小程序,2 H5,3 App 4 电脑
|
||||
typeId: 0, // 页面类型 0 C端 1 平台画布,2 自定义页面,3 商家店铺装修
|
||||
getToken: function(){
|
||||
return uni.getStorageSync('storage_key').token
|
||||
}
|
||||
}
|
||||
|
||||
// #ifdef H5
|
||||
config.terminal = 2
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS || APP-NVUE
|
||||
config.terminal = 3
|
||||
// #endif
|
||||
|
||||
// #ifdef MP
|
||||
config.terminal = 1
|
||||
// #endif
|
||||
|
||||
export default config
|
196
components/canvasShow/config/mixin/funMixin.js
Normal file
196
components/canvasShow/config/mixin/funMixin.js
Normal file
@ -0,0 +1,196 @@
|
||||
import sendReqMixin from './sendReqMixin'
|
||||
import { useRouter } from "@/hooks/useRouter";
|
||||
|
||||
export default function () {
|
||||
const {sendReq} = sendReqMixin()
|
||||
const {push} = useRouter()
|
||||
|
||||
// 请求数据前 请求完再显示所有组件
|
||||
function beforeGetData() {
|
||||
if (typeof uni !== 'undefined') {
|
||||
uni.getStorage({
|
||||
key: 'sendNum',
|
||||
success: function (res) {
|
||||
const sendNum = res.data
|
||||
uni.setStorage({key: 'sendNum', data: parseInt(sendNum) + 1})
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const sendNum = localStorage.getItem('sendNum')
|
||||
localStorage.setItem('sendNum', parseInt(sendNum) + 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 请求数据后
|
||||
function afterGetData() {
|
||||
if (typeof uni !== 'undefined') {
|
||||
uni.getStorage({
|
||||
key: 'sendNum',
|
||||
success: function (res) {
|
||||
const sendNum = res.data
|
||||
uni.setStorage({key: 'sendNum', data: parseInt(sendNum) - 1})
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const sendNum = localStorage.getItem('sendNum')
|
||||
localStorage.setItem('sendNum', parseInt(sendNum) - 1)
|
||||
}
|
||||
}
|
||||
|
||||
// 判断url
|
||||
function jumpLink(linkObj) {
|
||||
console.log(linkObj, 'linkObj')
|
||||
var link = ''
|
||||
if (linkObj?.typeText) {
|
||||
switch (linkObj.typeText) {
|
||||
case '类别':
|
||||
jumpCategory(linkObj.data.id)
|
||||
break
|
||||
case '店辅':
|
||||
jumpStore(linkObj.data)
|
||||
break
|
||||
case '商品':
|
||||
jumpProductDetail(linkObj.data)
|
||||
break
|
||||
case '自定义':
|
||||
// router.push("/category");
|
||||
case '公告':
|
||||
jumpNoticeDetail(linkObj.data)
|
||||
break
|
||||
case '产品':
|
||||
jumpProList()
|
||||
break
|
||||
case '秒杀':
|
||||
jumpSeckills()
|
||||
break
|
||||
case '拼团':
|
||||
jumpGroupWorks()
|
||||
break
|
||||
case '折扣':
|
||||
jumpDiscount()
|
||||
break
|
||||
}
|
||||
} else if (linkObj?.selsectValue === '/index') {
|
||||
uni.navigateTo({
|
||||
url: `/root/index/index`
|
||||
})
|
||||
}
|
||||
return link
|
||||
}
|
||||
|
||||
// 跳转到搜索
|
||||
function toSearch(key) {
|
||||
push({
|
||||
url: '/pages/search/search'
|
||||
}, {
|
||||
data: {key}
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到类别主页
|
||||
function jumpCategory(id) {
|
||||
push({
|
||||
url: '/pages/goodsList/goodsList'
|
||||
}, {
|
||||
data: {sid: id}
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到产品列表
|
||||
function jumpProList(item) {
|
||||
push({
|
||||
url: '/pages/goodsList/goodsList'
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到店铺主页
|
||||
function jumpStore(item) {
|
||||
uni.navigateTo({
|
||||
url: `/pages_category_page1/store/index?storeId=${ item.shopId }`
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到商品详情
|
||||
function jumpProductDetail(item) {
|
||||
push({url: '/pages/goodsDetail/goodsDetail'}, {data: {id:item.id,skuId:item.skuId}})
|
||||
}
|
||||
|
||||
// 跳转到秒杀专区
|
||||
function jumpSeckills() {
|
||||
push({url: '/pages/seckilling/seckilling'})
|
||||
}
|
||||
|
||||
// 跳转到拼团专区
|
||||
function jumpGroupWorks() {
|
||||
push({url: '/pages/groupBuy/groupBuy'})
|
||||
}
|
||||
|
||||
// 跳转到折扣专区
|
||||
function jumpDiscount() {
|
||||
push({url: '/pages/discount/discount'})
|
||||
}
|
||||
|
||||
// 跳转到会员专区
|
||||
function jumpVip() {
|
||||
uni.navigateTo({
|
||||
url: '/pages_category_page1/memberCenter/activityList',
|
||||
success: res => {
|
||||
}, fail: () => {
|
||||
}, complete: () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转组合支付
|
||||
function jumpCombination(item) {
|
||||
if (item.priceId) {
|
||||
uni.navigateTo({
|
||||
url: '/pages_category_page1/goodsModule/combination?priceId=' + item.priceId
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '暂无活动',
|
||||
icon: "none"
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转到公告详情
|
||||
function jumpNoticeDetail(item) {
|
||||
uni.navigateTo({
|
||||
url: '/pages_category_page2/userModule/messageDetail?noticeId=' + item.noticeId
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转到直播列表
|
||||
function jumpLive() {
|
||||
uni.navigateTo({
|
||||
url: '/pages_category_page2/livePage/index'
|
||||
})
|
||||
}
|
||||
|
||||
// 加入购物车
|
||||
function addCart(id) {
|
||||
console.log(id)
|
||||
}
|
||||
|
||||
return {
|
||||
beforeGetData,
|
||||
afterGetData,
|
||||
toSearch,
|
||||
sendReq,
|
||||
jumpLink,
|
||||
jumpCategory,
|
||||
jumpStore,
|
||||
jumpProductDetail,
|
||||
jumpSeckills,
|
||||
jumpGroupWorks,
|
||||
jumpDiscount,
|
||||
jumpVip,
|
||||
jumpNoticeDetail,
|
||||
addCart,
|
||||
jumpProList,
|
||||
jumpLive,
|
||||
jumpCombination
|
||||
}
|
||||
}
|
4
components/canvasShow/config/mixin/index.js
Normal file
4
components/canvasShow/config/mixin/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
import fun from './funMixin.js'
|
||||
import sendReq from './sendReqMixin.js'
|
||||
export const funMixin = fun
|
||||
export const sendReqMixin = sendReq
|
25
components/canvasShow/config/mixin/sendReqMixin.js
Normal file
25
components/canvasShow/config/mixin/sendReqMixin.js
Normal file
@ -0,0 +1,25 @@
|
||||
import { ref } from 'vue';
|
||||
import request from './server'
|
||||
|
||||
export default function () {
|
||||
const loading = ref(false)
|
||||
/*
|
||||
* 发送请求
|
||||
*/
|
||||
|
||||
function sendReq (params, callback) {
|
||||
request(params.url, params.data || {},params.method || 'POST',{
|
||||
'Content-type': params.contentType || 'application/json;charset=utf-8'
|
||||
}).then((res) => {
|
||||
if (res && res.data) {
|
||||
callback && callback(res.data)
|
||||
}
|
||||
}, (error) => {
|
||||
console.log(error)
|
||||
})
|
||||
}
|
||||
return {
|
||||
loading,
|
||||
sendReq
|
||||
}
|
||||
}
|
234
components/canvasShow/config/mixin/server.js
Normal file
234
components/canvasShow/config/mixin/server.js
Normal file
@ -0,0 +1,234 @@
|
||||
// 引入axios
|
||||
// import router from './../../router'
|
||||
// import * as Vue from 'vue'
|
||||
// import promise from 'es6-promise'
|
||||
import axios from 'axios'
|
||||
import canvasConfig from '../config'
|
||||
import cookie from '@/utils/cookie'
|
||||
// import Cookies from 'js-cookie'
|
||||
// import localStorage from '../storage/localStorage'
|
||||
// promise.polyfill()
|
||||
|
||||
/*
|
||||
const service = axios.create({
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
},
|
||||
withCredentials: true,
|
||||
timeout: 20000 // 请求超时 20s
|
||||
})
|
||||
|
||||
// 请求拦截器
|
||||
service.interceptors.request.use(config => {
|
||||
// 是否为当前的请求加上请求头 token
|
||||
const token = canvasConfig.getToken()
|
||||
if (token) {
|
||||
if(canvasConfig.typeId === 1){
|
||||
config.headers['Authorization-admin'] = token
|
||||
} else if(canvasConfig.typeId === 3){
|
||||
config.headers['Authorization-business'] = token
|
||||
} else {
|
||||
config.headers['Authorization'] = token
|
||||
}
|
||||
}
|
||||
return config
|
||||
}, error => {
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
||||
// 响应拦截器
|
||||
service.interceptors.response.use(
|
||||
(response) => {
|
||||
console.log(response)
|
||||
if (response.data.code && response.data.code !=='200' && response.data.message) {
|
||||
// Vue.prototype.$message.error(response.data.message)
|
||||
uni.showToast({
|
||||
title:response.data.message,
|
||||
icon:"none"
|
||||
})
|
||||
}
|
||||
return response
|
||||
},
|
||||
err => {
|
||||
console.log(err)
|
||||
// 失败响应
|
||||
if (err && err.response) {
|
||||
switch (err.response.status) {
|
||||
case 400:
|
||||
err.message = '请求无效,请检查参数是否正确!'
|
||||
break
|
||||
|
||||
case 401:
|
||||
err.message = '未经授权,访问被拒!'
|
||||
break
|
||||
|
||||
case 403:
|
||||
err.message = '拒绝访问!'
|
||||
break
|
||||
|
||||
case 404:
|
||||
err.message = `地址不存在!`
|
||||
break
|
||||
|
||||
case 408:
|
||||
err.message = '请求超时!'
|
||||
break
|
||||
|
||||
case 500:
|
||||
err.message = '系统错误!'
|
||||
break
|
||||
|
||||
case 501:
|
||||
err.message = '该方法未实现!'
|
||||
break
|
||||
|
||||
case 502:
|
||||
err.message = '网关出错!'
|
||||
break
|
||||
|
||||
case 503:
|
||||
err.message = '服务不可用!'
|
||||
break
|
||||
|
||||
case 504:
|
||||
err.message = '网关请求超时'
|
||||
break
|
||||
|
||||
case 505:
|
||||
err.message = 'HTTP版本不受支持'
|
||||
break
|
||||
|
||||
default:
|
||||
}
|
||||
if (err.response.data.error) {
|
||||
err.message = err.response.data.error
|
||||
}
|
||||
// Vue.prototype.$message.closeAll()
|
||||
// Vue.prototype.$message.error(err.message)
|
||||
uni.showToast({
|
||||
title:err.message,
|
||||
icon:"none"
|
||||
})
|
||||
// router.push({name: 'error', params: {message: err.message, status: err.response.status}})
|
||||
}
|
||||
}
|
||||
)
|
||||
*/
|
||||
|
||||
const request = (url,data,method='GET',header={})=>new Promise((resolve, reject)=>{
|
||||
// 是否为当前的请求加上请求头 token
|
||||
const token = cookie.get('accessToken')
|
||||
const headers = {...header}
|
||||
if (token.accessToken) {
|
||||
headers['Authorization'] = 'Bearer ' + token.accessToken
|
||||
}
|
||||
uni.request({
|
||||
url: url,
|
||||
data: data,
|
||||
method: method,
|
||||
header: headers,
|
||||
success: response => {
|
||||
if (response.data.code && response.data.code !=='200' && response.data.message) {
|
||||
uni.showToast({
|
||||
title:response.data.message,
|
||||
icon:"none"
|
||||
})
|
||||
}else{
|
||||
resolve(response)
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
// 失败响应
|
||||
if (err && err.response) {
|
||||
switch (err.response.status) {
|
||||
case 400:
|
||||
err.message = '请求无效,请检查参数是否正确!'
|
||||
break
|
||||
|
||||
case 401:
|
||||
err.message = '未经授权,访问被拒!'
|
||||
break
|
||||
|
||||
case 403:
|
||||
err.message = '拒绝访问!'
|
||||
break
|
||||
|
||||
case 404:
|
||||
err.message = `地址不存在!`
|
||||
break
|
||||
|
||||
case 408:
|
||||
err.message = '请求超时!'
|
||||
break
|
||||
|
||||
case 500:
|
||||
err.message = '系统错误!'
|
||||
break
|
||||
|
||||
case 501:
|
||||
err.message = '该方法未实现!'
|
||||
break
|
||||
|
||||
case 502:
|
||||
err.message = '网关出错!'
|
||||
break
|
||||
|
||||
case 503:
|
||||
err.message = '服务不可用!'
|
||||
break
|
||||
|
||||
case 504:
|
||||
err.message = '网关请求超时'
|
||||
break
|
||||
|
||||
case 505:
|
||||
err.message = 'HTTP版本不受支持'
|
||||
break
|
||||
|
||||
default:
|
||||
}
|
||||
if (err.response.data.error) {
|
||||
err.message = err.response.data.error
|
||||
}
|
||||
// Vue.prototype.$message.closeAll()
|
||||
// Vue.prototype.$message.error(err.message)
|
||||
uni.showToast({
|
||||
title:err.message,
|
||||
icon:"none"
|
||||
})
|
||||
reject(err)
|
||||
// router.push({name: 'error', params: {message: err.message, status: err.response.status}})
|
||||
}
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
//真机获取
|
||||
// service.defaults.adapter = function (config) {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// console.log(config)
|
||||
// var settle = require('axios/lib/core/settle');
|
||||
// var buildURL = require('axios/lib/helpers/buildURL');
|
||||
// uni.request({
|
||||
// method: config.method.toUpperCase(),
|
||||
// url: buildURL(config.url, config.params, config.paramsSerializer),
|
||||
// header: config.headers,
|
||||
// data: config.data,
|
||||
// dataType: config.dataType,
|
||||
// responseType: config.responseType,
|
||||
// sslVerify: config.sslVerify,
|
||||
// complete:function complete(response){
|
||||
// response = {
|
||||
// data: response.data,
|
||||
// status: response.statusCode,
|
||||
// errMsg: response.errMsg,
|
||||
// header: response.header,
|
||||
// config: config
|
||||
// };
|
||||
//
|
||||
// settle(resolve, reject, response);
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
export default request
|
Reference in New Issue
Block a user