feat: 功能开发

pull/2/head
TianYu 2023-05-16 18:00:52 +08:00
parent ca7f62f924
commit 24b4be91d0
17 changed files with 563 additions and 627 deletions

View File

@ -1,26 +1,30 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<doc-alert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/" /> <doc-alert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/"/>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="租户名" prop="name"> <el-form-item label="租户名" prop="name">
<el-input v-model="queryParams.name" placeholder="请输入租户名" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.name" placeholder="请输入租户名" clearable @keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="联系人" prop="contactName"> <el-form-item label="联系人" prop="contactName">
<el-input v-model="queryParams.contactName" placeholder="请输入联系人" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.contactName" placeholder="请输入联系人" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="联系手机" prop="contactMobile"> <el-form-item label="联系手机" prop="contactMobile">
<el-input v-model="queryParams.contactMobile" placeholder="请输入联系手机" clearable @keyup.enter.native="handleQuery"/> <el-input v-model="queryParams.contactMobile" placeholder="请输入联系手机" clearable
@keyup.enter.native="handleQuery"/>
</el-form-item> </el-form-item>
<el-form-item label="租户状态" prop="status"> <el-form-item label="租户状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择租户状态" clearable> <el-select v-model="queryParams.status" placeholder="请选择租户状态" clearable>
<el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="dict.label" :value="dict.value"/> :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建时间" prop="createTime"> <el-form-item label="创建时间" prop="createTime">
<el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" /> type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"/>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button> <el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
@ -32,54 +36,47 @@
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['system:tenant:create']">新增</el-button> v-hasPermi="['system:tenant:create']">新增
</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading" <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['system:tenant:export']">导出</el-button> :loading="exportLoading"
v-hasPermi="['system:tenant:export']">导出
</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<!-- 列表 --> <!-- 列表 -->
<el-table v-loading="loading" :data="list"> <el-table v-loading="loading" :data="list">
<el-table-column label="租户编号" align="center" prop="id" /> <el-table-column label="编号" align="center" prop="id"/>
<el-table-column label="租户名" align="center" prop="name" /> <el-table-column label="店铺LOGO" align="center" prop="logo">
<el-table-column label="租户套餐" align="center" prop="packageId">
<template v-slot="scope"> <template v-slot="scope">
<el-tag v-if="scope.row.packageId === 0" type="danger"></el-tag> <img :src="scope.row.logo" width="50" height="50" />
<el-tag v-else> {{getPackageName(scope.row.packageId)}} </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="联系人" align="center" prop="contactName" /> <el-table-column label="店铺名称" align="center" prop="name"/>
<el-table-column label="联系手机" align="center" prop="contactMobile" /> <el-table-column label="销售对接人" align="center" prop="saleContactName"/>
<el-table-column label="账号额度" align="center" prop="accountCount"> <el-table-column label="销售对接号码" align="center" prop="saleContactMobile"/>
<template v-slot="scope"> <el-table-column label="店铺负责人" align="center" prop="contactName"/>
<el-tag> {{scope.row.accountCount}} </el-tag> <el-table-column label="店铺负责人号码" align="center" prop="contactMobile"/>
</template> <el-table-column label="店铺状态" align="center" prop="status">
</el-table-column>
<el-table-column label="过期时间" align="center" prop="expireTime" width="180">
<template v-slot="scope">
<span>{{ parseTime(scope.row.expireTime) }}</span>
</template>
</el-table-column>
<el-table-column label="绑定域名" align="center" prop="domain" width="180" />
<el-table-column label="租户状态" align="center" prop="status">
<template v-slot="scope"> <template v-slot="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template v-slot="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope"> <template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" <el-button size="mini" type="text" @click="handleLook(scope.row)"
v-hasPermi="['system:tenant:update']">修改</el-button> v-hasPermi="['system:tenant:update']">查看
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" </el-button>
v-hasPermi="['system:tenant:delete']">删除</el-button> <el-button size="mini" type="text" @click="handleUpdate(scope.row)"
v-hasPermi="['system:tenant:update']">编辑
</el-button>
<el-button size="mini" type="text" @click="handleDelete(scope.row)"
v-hasPermi="['system:tenant:delete']">禁用
</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -88,44 +85,77 @@
@pagination="getList"/> @pagination="getList"/>
<!-- 对话框(添加 / 修改) --> <!-- 对话框(添加 / 修改) -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form ref="form" :model="form" :rules="rules" label-width="140px" :disabled="isLook">
<el-form-item label="租户名" prop="name"> <el-row>
<el-input v-model="form.name" placeholder="请输入租户名" /> <el-col :span="12">
</el-form-item> <el-form-item label="店铺名称" prop="name">
<el-form-item label="租户套餐" prop="packageId"> <el-input v-model="form.name" placeholder="请输入"/>
<el-select v-model="form.packageId" placeholder="请选择租户套餐" clearable size="small"> </el-form-item>
<el-option v-for="item in packageList" :key="item.id" :label="item.name" :value="item.id"/> </el-col>
</el-select> <el-col :span="12">
</el-form-item> <el-form-item label="微信客户地址" prop="wxKfUrl">
<el-form-item label="联系人" prop="contactName"> <el-input v-model="form.wxKfUrl" placeholder="请输入"/>
<el-input v-model="form.contactName" placeholder="请输入联系人" /> </el-form-item>
</el-form-item> </el-col>
<el-form-item label="联系手机" prop="contactMobile"> </el-row>
<el-input v-model="form.contactMobile" placeholder="请输入联系手机" /> <el-row>
</el-form-item> <el-col :span="12">
<el-form-item v-if="form.id === undefined" label="用户名称" prop="username"> <el-form-item label="销售对接人" prop="saleContactName">
<el-input v-model="form.username" placeholder="请输入用户名称" /> <el-input v-model="form.saleContactName" placeholder="请输入"/>
</el-form-item> </el-form-item>
<el-form-item v-if="form.id === undefined" label="用户密码" prop="password"> </el-col>
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" show-password /> <el-col :span="12">
</el-form-item> <el-form-item label="销售对接号码" prop="saleContactMobile">
<el-form-item label="账号额度" prop="accountCount"> <el-input v-model="form.saleContactMobile" placeholder="请输入"/>
<el-input-number v-model="form.accountCount" placeholder="请输入账号额度" controls-position="right" :min="0" /> </el-form-item>
</el-form-item> </el-col>
<el-form-item label="过期时间" prop="expireTime"> </el-row>
<el-date-picker clearable size="small" v-model="form.expireTime" type="date" <el-row>
value-format="timestamp" placeholder="请选择过期时间" /> <el-col :span="12">
</el-form-item> <el-form-item label="店铺负责人" prop="contactName">
<el-form-item label="绑定域名" prop="domain"> <el-input v-model="form.contactName" placeholder="请输入"/>
<el-input v-model="form.domain" placeholder="请输入绑定域名" /> </el-form-item>
</el-form-item> </el-col>
<el-form-item label="租户状态" prop="status"> <el-col :span="12">
<el-radio-group v-model="form.status"> <el-form-item label="店铺负责人号码" prop="contactMobile">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" <el-input v-model="form.contactMobile" placeholder="请输入"/>
:key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> </el-form-item>
</el-radio-group> </el-col>
</el-form-item> </el-row>
<el-row>
<el-col :span="12">
<el-form-item label="店铺LOGO图片" prop="logo">
<el-input v-model="form.logo" placeholder="请输入"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="店铺状态" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :label="parseInt(dict.value)">{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-form-item label="店铺简介" prop="introduction">
<el-input v-model="form.introduction" placeholder="请输入"/>
</el-form-item>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="服务时间" prop="serviceTime">
<el-input v-model="form.serviceTime" placeholder="请输入"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="服务电话" prop="serviceMobile">
<el-input v-model="form.serviceMobile" placeholder="请输入"/>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button> <el-button type="primary" @click="submitForm"> </el-button>
@ -136,14 +166,20 @@
</template> </template>
<script> <script>
import { createTenant, updateTenant, deleteTenant, getTenant, getTenantPage, exportTenantExcel } from "@/api/system/tenant"; import {
import { CommonStatusEnum } from '@/utils/constants' createTenant,
import {getTenantPackageList} from "@/api/system/tenantPackage"; updateTenant,
deleteTenant,
getTenant,
getTenantPage,
exportTenantExcel
} from '@/api/system/tenant';
import {CommonStatusEnum} from '@/utils/constants'
import {getTenantPackageList} from '@/api/system/tenantPackage';
export default { export default {
name: "SystemTenant", name: 'SystemTenant',
components: { components: {},
},
data() { data() {
return { return {
// //
@ -159,7 +195,7 @@ export default {
// //
packageList: [], packageList: [],
// //
title: "", title: '',
// //
open: false, open: false,
// //
@ -174,17 +210,44 @@ export default {
}, },
// //
form: {}, form: {},
isLook: false,
// //
rules: { rules: {
name: [{ required: true, message: "租户名不能为空", trigger: "blur" }], name: [{
packageId: [{ required: true, message: "租户套餐不能为空", trigger: "blur" }], required: true,
contactName: [{ required: true, message: "联系人不能为空", trigger: "blur" }], message: '名称不能为空',
status: [{ required: true, message: "租户状态不能为空", trigger: "blur" }], trigger: 'blur'
accountCount: [{ required: true, message: "账号额度不能为空", trigger: "blur" }], }],
expireTime: [{ required: true, message: "过期时间不能为空", trigger: "blur" }], wxKfUrl: [{
domain: [{ required: true, message: "绑定域名不能为空", trigger: "blur" }], required: true,
username: [{ required: true, message: "用户名称不能为空", trigger: "blur" }], message: '微信客服地址不能为空',
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }], trigger: 'blur'
}],
contactName: [{
required: true,
message: '店铺负责人不能为空',
trigger: 'blur'
}],
contactMobile: [{
required: true,
message: '店铺负责人号码不能为空',
trigger: 'blur'
}],
introduction: [{
required: true,
message: '店铺简介不能为空',
trigger: 'blur'
}],
serviceTime: [{
required: true,
message: '服务不能为空',
trigger: 'blur'
}],
serviceMobile: [{
required: true,
message: '服务不能为空',
trigger: 'blur'
}]
} }
}; };
}, },
@ -224,7 +287,7 @@ export default {
domain: undefined, domain: undefined,
status: CommonStatusEnum.ENABLE, status: CommonStatusEnum.ENABLE,
}; };
this.resetForm("form"); this.resetForm('form');
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
@ -233,35 +296,44 @@ export default {
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm('queryForm');
this.handleQuery(); this.handleQuery();
}, },
handleLook(row){
this.form = row
this.open = true
this.isLook = true
this.title = '查看店铺'
},
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset();
this.open = true; this.open = true;
this.title = "添加租户"; this.isLook = false;
this.title = '添加店铺';
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
this.isLook = false;
const id = row.id; const id = row.id;
getTenant(id).then(response => { getTenant(id).then(response => {
this.form = response.data; this.form = response.data;
this.open = true; this.open = true;
this.title = "修改租户"; this.title = '修改店铺';
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {
this.$refs["form"].validate(valid => { this.$refs['form'].validate(valid => {
if (!valid) { if (!valid) {
return; return;
} }
// //
if (this.form.id != null) { if (this.form.id != null) {
updateTenant(this.form).then(response => { updateTenant(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess('修改成功');
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -269,7 +341,7 @@ export default {
} }
// //
createTenant(this.form).then(response => { createTenant(this.form).then(response => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess('新增成功');
this.open = false; this.open = false;
this.getList(); this.getList();
}); });
@ -278,12 +350,13 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const id = row.id; const id = row.id;
this.$modal.confirm('是否确认删除租户编号为"' + id + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除店铺编号为"' + id + '"的数据项?').then(function () {
return deleteTenant(id); return deleteTenant(id);
}).then(() => { }).then(() => {
this.getList(); this.getList();
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess('删除成功');
}).catch(() => {}); }).catch(() => {
});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
@ -293,12 +366,13 @@ export default {
params.pageSize = undefined; params.pageSize = undefined;
// //
this.$modal.confirm('是否确认导出所有租户数据项?').then(() => { this.$modal.confirm('是否确认导出所有租户数据项?').then(() => {
this.exportLoading = true; this.exportLoading = true;
return exportTenantExcel(params); return exportTenantExcel(params);
}).then(response => { }).then(response => {
this.$download.excel(response, '租户.xls'); this.$download.excel(response, '租户.xls');
this.exportLoading = false; this.exportLoading = false;
}).catch(() => {}); }).catch(() => {
});
}, },
/** 套餐名格式化 */ /** 套餐名格式化 */
getPackageName(packageId) { getPackageName(packageId) {

View File

@ -1,224 +1,249 @@
<script> <script>
import { import {
checkLogin checkLogin
} from "./libs/login"; } from "./libs/login";
import { import {
HTTP_REQUEST_URL refreshToken
} from './config/app'; } from "@/api/api";
import Auth from './libs/wechat.js'; import {
import Routine from './libs/routine.js'; HTTP_REQUEST_URL
import Apps from './libs/apps.js'; } from './config/app';
import { import Auth from './libs/wechat.js';
mapActions import Routine from './libs/routine.js';
} from 'vuex' import Apps from './libs/apps.js';
import {
mapActions
} from 'vuex'
export default { export default {
globalData: { globalData: {
spid: 0, spid: 0,
code: 0, code: 0,
isLogin: false, isLogin: false,
userInfo: {}, userInfo: {},
MyMenus: [], MyMenus: [],
windowHeight: 0, windowHeight: 0,
id: 0 id: 0
}, },
onLaunch: function(option) { onLaunch: function(option) {
let that = this; let that = this;
// #ifdef H5 // #ifdef H5
uni.getSystemInfo({ uni.getSystemInfo({
success: function(res) { success: function(res) {
// title // title
// 44px // 44px
let height = res.windowHeight - res.statusBarHeight - 44 let height = res.windowHeight - res.statusBarHeight - 44
// #ifdef H5 // #ifdef H5
that.globalData.windowHeight = res.windowHeight + 'px' that.globalData.windowHeight = res.windowHeight + 'px'
// #endif // #endif
} }
}); });
// #endif // #endif
// #ifdef MP // #ifdef MP
if (HTTP_REQUEST_URL == '') { if (HTTP_REQUEST_URL == '') {
console.error( console.error(
"请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret" "请配置根目录下的config.js文件中的 'HTTP_REQUEST_URL'\n\n请修改开发者工具中【详情】->【AppID】改为自己的Appid\n\n请前往后台【小程序】->【小程序配置】填写自己的 appId and AppSecret"
); );
return false; return false;
} }
if (option.query.hasOwnProperty('scene')) { if (option.query.hasOwnProperty('scene')) {
switch(option.scene){ switch (option.scene) {
case 1047: // case 1047: //
case 1048: // case 1048: //
case 1049: // case 1049: //
case 1001: // case 1001: //
let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene)); let value = this.$util.getUrlParams(decodeURIComponent(option.query.scene));
let values = value.split(','); let values = value.split(',');
if(values.length === 2){ if (values.length === 2) {
let v1 = values[0].split(":"); let v1 = values[0].split(":");
if (v1[0] === 'pid') { if (v1[0] === 'pid') {
that.globalData.spid = v1[1]; that.globalData.spid = v1[1];
} else{ } else {
that.globalData.id = v1[1]; that.globalData.id = v1[1];
} }
let v2 = values[1].split(":"); let v2 = values[1].split(":");
if (v2[0] === 'pid') { if (v2[0] === 'pid') {
that.globalData.spid = v2[1]; that.globalData.spid = v2[1];
}else{ } else {
that.globalData.id = v2[1]; that.globalData.id = v2[1];
} }
}else{ } else {
that.globalData.spid = values[0].split(":")[1]; that.globalData.spid = values[0].split(":")[1];
} }
break; break;
} }
} }
// #endif // #endif
// //
uni.getSystemInfo({ uni.getSystemInfo({
success: function(res) { success: function(res) {
that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91; that.globalData.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
} }
}); });
// #ifdef MP // #ifdef MP
let menuButtonInfo = uni.getMenuButtonBoundingClientRect(); let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2; that.globalData.navH = menuButtonInfo.top * 2 + menuButtonInfo.height / 2;
// #endif // #endif
// #ifdef H5 // #ifdef H5
let snsapiBase = 'snsapi_base'; let snsapiBase = 'snsapi_base';
let urlData = location.pathname + location.search; let urlData = location.pathname + location.search;
if (!that.$store.getters.isLogin && Auth.isWeixin()) { if (!that.$store.getters.isLogin && Auth.isWeixin()) {
const { const {
code, code,
state, state,
scope scope
} = option.query; } = option.query;
if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf( if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf(
'/pages/users/wechat_login/index') === -1) { '/pages/users/wechat_login/index') === -1) {
// code // code
uni.setStorageSync('snsapiCode', code); uni.setStorageSync('snsapiCode', code);
let spread = that.globalData.spid ? that.globalData.spid : 0; let spread = that.globalData.spid ? that.globalData.spid : 0;
Auth.auth(code, that.$Cache.get('spread')) Auth.auth(code, that.$Cache.get('spread'))
.then(res => { .then(res => {
uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query uni.setStorageSync('snRouter', decodeURIComponent(decodeURIComponent(option.query
.back_url))); .back_url)));
if (res.type === 'register') { if (res.type === 'register') {
this.$Cache.set('snsapiKey', res.key); this.$Cache.set('snsapiKey', res.key);
} }
if (res.type === 'login') { if (res.type === 'login') {
this.$store.commit('LOGIN', { this.$store.commit('LOGIN', {
token: res.token token: res.token
}); });
this.$store.commit("SETUID", res.uid); this.$store.commit("SETUID", res.uid);
location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url))); location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
} }
}) })
.catch(error => { .catch(error => {
// this.$util.Tips({ // this.$util.Tips({
// title: error // title: error
// }); // });
if (!this.$Cache.has('snsapiKey')) { if (!this.$Cache.has('snsapiKey')) {
if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) { if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
Auth.oAuth(snsapiBase, option.query.back_url); Auth.oAuth(snsapiBase, option.query.back_url);
} }
} }
}); });
} else { } else {
if (!this.$Cache.has('snsapiKey')) { if (!this.$Cache.has('snsapiKey')) {
if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) { if (location.pathname.indexOf('/pages/users/wechat_login/index') === -1) {
Auth.oAuth(snsapiBase, urlData); Auth.oAuth(snsapiBase, urlData);
} }
} }
} }
} else { } else {
if (option.query.back_url) { if (option.query.back_url) {
location.replace(uni.getStorageSync('snRouter')); location.replace(uni.getStorageSync('snRouter'));
} }
} }
// #endif // #endif
// #ifdef MP // #ifdef MP
// //
if (!this.$store.getters.isLogin) { if (!this.$store.getters.isLogin) {
let spread = that.globalData.spid ? that.globalData.spid : 0; let spread = that.globalData.spid ? that.globalData.spid : 0;
Routine.getCode() Routine.getCode()
.then(code => { .then(code => {
Routine.authUserInfo(code, { Routine.authUserInfo(code, {
'spread_spid': spread 'spread_spid': spread
}).then(res => { }).then(res => {
// that.$store.commit('AuthorizeType', res.data.type); // that.$store.commit('AuthorizeType', res.data.type);
}) })
}) })
.catch(res => { .catch(res => {
uni.hideLoading(); uni.hideLoading();
}); });
} }
// #endif // #endif
}, },
async mounted() { async mounted() {
if(this.$store.getters.isLogin && !this.$Cache.get('USER_INFO'))await this.$store.dispatch('USERINFO'); if (this.$store.getters.isLogin && !this.$Cache.get('USER_INFO')) {
}, await this.$store.dispatch('USERINFO');
methods: { }
}, setInterval(() => {
onShow: function() { if (this.$store.getters.isLogin) {
// #ifdef H5 this.setRefreshToken()
uni.getSystemInfo({ }
success(e) { }, 60000)
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */ },
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) { methods: {
// window.location.pathname = 'https://java.crmeb.net/'; setRefreshToken() {
/* 若你的项目未设置根目录(默认为 / 时),则使用下方代码 */ refreshToken(this.$Cache.get("REFRESH_TOKEN"))
window.location.pathname = '/static/html/pc.html'; .then(res => {
} let data = res.data;
} this.$store.commit("LOGIN", {
}) 'token': data.accessToken,
// #endif 'refreshToken': data.refreshToken
}, });
onHide: function() { })
//console.log('App Hide') .catch(res => {
} this.$util.Tips({
} title: res
});
});
}
},
onShow: function() {
// #ifdef H5
uni.getSystemInfo({
success(e) {
/* 窗口宽度大于420px且不在PC页面且不在移动设备时跳转至 PC.html 页面 */
if (e.windowWidth > 420 && !window.top.isPC && !/iOS|Android/i.test(e.system)) {
// window.location.pathname = 'https://java.crmeb.net/';
/* 若你的项目未设置根目录(默认为 / 时),则使用下方代码 */
window.location.pathname = '/static/html/pc.html';
}
}
})
// #endif
},
onHide: function() {
//console.log('App Hide')
}
}
</script> </script>
<style> <style>
@import url("@/plugin/animate/animate.min.css"); @import url("@/plugin/animate/animate.min.css");
@import 'static/css/base.css'; @import 'static/css/base.css';
@import 'static/iconfont/iconfont.css'; @import 'static/iconfont/iconfont.css';
@import 'static/css/guildford.css'; @import 'static/css/guildford.css';
@import 'static/css/style.scss'; @import 'static/css/style.scss';
/* 条件编译仅在H5平台生效 */ /* 条件编译仅在H5平台生效 */
// #ifdef H5 // #ifdef H5
body::-webkit-scrollbar, body::-webkit-scrollbar,
html::-webkit-scrollbar { html::-webkit-scrollbar {
display: none; display: none;
} }
// #endif // #endif
view { view {
box-sizing: border-box; box-sizing: border-box;
} }
.bg-color-red { .bg-color-red {
background-color: #E93323 !important; background-color: #E93323 !important;
} }
.syspadding { .syspadding {
padding-top: var(--status-bar-height); padding-top: var(--status-bar-height);
} }
.flex { .flex {
display: flex; display: flex;
} }
.uni-scroll-view::-webkit-scrollbar { .uni-scroll-view::-webkit-scrollbar {
/* 隐藏滚动条,但依旧具备可以滚动的功能 */ /* 隐藏滚动条,但依旧具备可以滚动的功能 */
display: none display: none
} }
::-webkit-scrollbar { ::-webkit-scrollbar {
width: 0; width: 0;
height: 0; height: 0;
color: transparent; color: transparent;
} }
</style> </style>

View File

@ -22,6 +22,11 @@ export function getLogo()
return request.get('wechat/getLogo', {}, { noAuth : true}); return request.get('wechat/getLogo', {}, { noAuth : true});
} }
export function refreshToken(token)
{
return request.post('member/auth/refresh-token?refreshToken=' + token, {}, { noAuth : true});
}
/** /**
* 保存form_id * 保存form_id
@ -211,7 +216,7 @@ export function pink()
* 获取城市信息 * 获取城市信息
*/ */
export function getCity() { export function getCity() {
return request.get('city/list', { }, { noAuth: true }); return request.get('area/tree', { }, { noAuth: true });
} }
/** /**

View File

@ -5,9 +5,10 @@ import Cache from "@/utils/cache.js"
* *
*/ */
export function getUserInfo(){ export function getUserInfo(){
return request.get('user'); return request.get('member/user/get');
} }
/** /**
* 设置用户分享 * 设置用户分享
* *
@ -43,8 +44,8 @@ export function getCodeApi() {
* h5用户发送验证码 * h5用户发送验证码
* @param data object 用户手机号 * @param data object 用户手机号
*/ */
export function registerVerify(phone){ export function registerVerify(phone, scene){
return request.post('member/auth/send-sms-code', { mobile: phone, scene: 4 },{noAuth:true},1) return request.post('member/auth/send-sms-code', { mobile: phone, scene },{noAuth:true},1)
} }
/** /**
@ -60,7 +61,7 @@ export function register(data) {
* @param data object 用户手机号 验证码 密码 * @param data object 用户手机号 验证码 密码
*/ */
export function registerReset(data) { export function registerReset(data) {
return request.post("register/reset", data, { noAuth: true }); return request.post("member/auth/reset-password", data, { noAuth: true });
} }
/** /**
@ -290,14 +291,14 @@ export function getAddressDetail(id){
* @param object * @param object
*/ */
export function userEdit(data){ export function userEdit(data){
return request.post('user/edit',data); return request.post('member/user/update-user',data);
} }
/* /*
* 退出登录 * 退出登录
* */ * */
export function getLogout() { export function getLogout() {
return request.get("logout"); return request.post("member/auth/logout");
} }
/** /**
* 小程序充值 * 小程序充值

View File

@ -21,7 +21,7 @@ module.exports = {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
}, },
// 回话密钥名称 请勿修改此配置 // 回话密钥名称 请勿修改此配置
TOKENNAME: 'Authori-zation', TOKENNAME: 'Authorization',
// 缓存时间 0 永久 // 缓存时间 0 永久
EXPIRE:0, EXPIRE:0,
//分页最多显示条数 //分页最多显示条数

View File

@ -1,6 +1,7 @@
module.exports = { module.exports = {
//token //token
LOGIN_STATUS: 'LOGIN_STATUS_TOKEN', LOGIN_STATUS: 'LOGIN_STATUS_TOKEN',
REFRESH_TOKEN: 'REFRESH_TOKEN',
// uid // uid
UID:'UID', UID:'UID',
//用户信息 //用户信息

View File

@ -241,6 +241,12 @@
"navigationBarTitleText": "地址管理" "navigationBarTitleText": "地址管理"
} }
}, },
{
"path": "user_spread_user/index",
"style": {
"navigationBarTitleText": "分销中心"
}
},
{ {
"path": "user_address/index", "path": "user_address/index",
"style": { "style": {
@ -522,6 +528,12 @@
"selectedIconPath": "static/images/2-002.png", "selectedIconPath": "static/images/2-002.png",
"text": "分类" "text": "分类"
}, },
{
"pagePath": "pages/order_addcart/order_addcart",
"iconPath": "static/images/3-001.png",
"selectedIconPath": "static/images/3-002.png",
"text": "会员申请"
},
{ {
"pagePath": "pages/order_addcart/order_addcart", "pagePath": "pages/order_addcart/order_addcart",
"iconPath": "static/images/3-001.png", "iconPath": "static/images/3-001.png",

View File

@ -21,33 +21,33 @@
</view> </view>
</view> </view>
</view> </view>
<view class="num" v-if="userInfo.phone && uid" @click="goEdit()"> <view class="num" v-if="userInfo.mobile && uid" @click="goEdit()">
<view class="num-txt">{{userInfo.phone}}</view> <view class="num-txt">{{userInfo.mobile}}</view>
<view class="icon"> <view class="icon">
<image src="/static/images/edit.png" mode=""></image> <image src="/static/images/edit.png" mode=""></image>
</view> </view>
</view> </view>
<view class="phone" v-if="!userInfo.phone && isLogin" @tap="bindPhone"></view> <view class="phone" v-if="!userInfo.mobile && isLogin" @tap="bindPhone"></view>
</view> </view>
</view> </view>
<view class="num-wrapper"> <view class="num-wrapper">
<view class="num-item" @click="goMenuPage('/pages/users/user_money/index')"> <!-- <view class="num-item" @click="goMenuPage('/pages/users/user_money/index')">
<text <text
class="num">{{userInfo.nowMoney && uid ?Number(userInfo.nowMoney).toFixed(2):0}}</text> class="num">{{userInfo.nowMoney && uid ?Number(userInfo.nowMoney).toFixed(2):0}}</text>
<view class="txt">余额</view> <view class="txt">余额</view>
</view> </view> -->
<view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')"> <view class="num-item" @click="goMenuPage('/pages/users/user_integral/index')">
<text class="num">{{userInfo.integral && uid ? userInfo.integral: 0}}</text> <text class="num">{{userInfo.integral && uid ? userInfo.integral: 0}}</text>
<view class="txt">积分</view> <view class="txt">积分</view>
</view> </view>
<view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')"> <!-- <view class="num-item" @click="goMenuPage('/pages/users/user_coupon/index')">
<text class="num">{{userInfo.couponCount && uid ? userInfo.couponCount : 0}}</text> <text class="num">{{userInfo.couponCount && uid ? userInfo.couponCount : 0}}</text>
<view class="txt">优惠券</view> <view class="txt">优惠券</view>
</view> </view>
<view class="num-item" @click="goMenuPage('/pages/users/user_goods_collection/index')"> <view class="num-item" @click="goMenuPage('/pages/users/user_goods_collection/index')">
<text class="num">{{userInfo.collectCount && uid ? userInfo.collectCount : 0}}</text> <text class="num">{{userInfo.collectCount && uid ? userInfo.collectCount : 0}}</text>
<view class="txt">收藏</view> <view class="txt">收藏</view>
</view> </view> -->
</view> </view>
<!-- <view class="sign" @click="goSignIn"></view> --> <!-- <view class="sign" @click="goSignIn"></view> -->
</view> </view>
@ -91,11 +91,15 @@
<view class="menu-title">我的服务</view> <view class="menu-title">我的服务</view>
<view class="list-box"> <view class="list-box">
<block v-for="(item,index) in MyMenus" :key="index"> <block v-for="(item,index) in MyMenus" :key="index">
<navigator class="item" :url="item.url" hover-class="none" <!-- <navigator class="item" :url="item.url" hover-class="none"
v-if="!(item.url =='/pages/service/index' || (item.url =='/pages/users/user_spread_user/index' && !userInfo.isPromoter))"> v-if="!(item.url =='/pages/service/index' || (item.url =='/pages/users/user_spread_user/index' && !userInfo.isPromoter))">
<image :src="item.pic"></image> <image :src="item.pic"></image>
<text>{{item.name}}</text> <text>{{item.name}}</text>
</navigator> </navigator> -->
<navigator class="item" :url="item.url" hover-class="none">
<image :src="item.pic"></image>
<text>{{item.name}}</text>
</navigator>
</block> </block>
<!-- #ifndef MP --> <!-- #ifndef MP -->
<view class="item" @click="kefuClick"> <view class="item" @click="kefuClick">
@ -187,7 +191,18 @@
isAuto: false, // isAuto: false, //
isShowAuth: false, // isShowAuth: false, //
orderStatusNum: {}, orderStatusNum: {},
MyMenus: [], MyMenus: [
{
pic: '/static/images/address.png',
url: '/pages/users/user_address_list/index',
name: '收货地址'
},
{
pic: '/static/images/record4.png',
url: '/pages/users/user_spread_user/index',
name: '分销中心'
},
],
wechatUrl: [], wechatUrl: [],
servicePic: '/static/images/customer.png', servicePic: '/static/images/customer.png',
sysHeight: sysHeight, sysHeight: sysHeight,
@ -207,7 +222,7 @@
// #ifdef H5 // #ifdef H5
that.$set(that, 'pageHeight', app.globalData.windowHeight); that.$set(that, 'pageHeight', app.globalData.windowHeight);
// #endif // #endif
that.$set(that, 'MyMenus', app.globalData.MyMenus); // that.$set(that, 'MyMenus', app.globalData.MyMenus);
if (!this.$Cache.has('cityList')) this.getCityList(); if (!this.$Cache.has('cityList')) this.getCityList();
if (that.isLogin == false) { if (that.isLogin == false) {
// #ifdef H5 // #ifdef H5
@ -225,7 +240,6 @@
}); });
// #endif // #endif
if (that.isLogin) { if (that.isLogin) {
this.getMyMenus();
// this.setVisit(); // this.setVisit();
this.getOrderData(); this.getOrderData();
this.$store.dispatch('USERINFO'); this.$store.dispatch('USERINFO');
@ -278,7 +292,7 @@
}, },
// //
onLoadFun() { onLoadFun() {
this.getMyMenus(); // this.getMyMenus();
// this.setVisit(); // this.setVisit();
this.getOrderData(); this.getOrderData();
}, },
@ -299,26 +313,6 @@
url: '/pages/users/app_login/index' url: '/pages/users/app_login/index'
}) })
}, },
/**
*
* 获取个人中心图标
*/
getMyMenus: function() {
let that = this;
if (this.MyMenus.length) return;
getMenuList().then(res => {
that.$set(that, 'MyMenus', res.data.routine_my_menus);
that.wechatUrl = res.data.routine_my_menus.filter((item) => {
return item.url.indexOf('service') !== -1
})
res.data.routine_my_menus.map((item) => {
if (item.url.indexOf('service') !== -1) that.servicePic = item.pic
})
if(res.data.routine_my_banner){
that.imgUrls = res.data.routine_my_banner
}
});
},
// //
goEdit() { goEdit() {
if (this.isLogin == false) { if (this.isLogin == false) {

View File

@ -5,7 +5,7 @@
<image :src="logoUrl"/> <image :src="logoUrl"/>
<!-- <image src="/static/images/logo2.png" v-if="!logoUrl" /> --> <!-- <image src="/static/images/logo2.png" v-if="!logoUrl" /> -->
</div> </div>
<div class="whiteBg" v-if="formItem === 1"> <div class="whiteBg">
<div class="list" v-if="current !== 1"> <div class="list" v-if="current !== 1">
<form @submit.prevent="submit"> <form @submit.prevent="submit">
<div class="item"> <div class="item">
@ -22,7 +22,7 @@
</div> </div>
</form> </form>
</div> </div>
<div class="list" v-if="current !== 0 || appLoginStatus || appleLoginStatus"> <div class="list" v-if="current !== 0">
<div class="item"> <div class="item">
<div class="acea-row row-middle"> <div class="acea-row row-middle">
<image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image> <image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
@ -38,18 +38,12 @@
</button> </button>
</div> </div>
</div> </div>
<div class="item" v-if="isShowCode">
<div class="acea-row row-middle">
<image src="/static/images/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
<input type="text" placeholder="填写验证码" class="codeIput" v-model="codeVal" />
<div class="code" @click="again"><img :src="codeUrl" /></div>
</div>
</div>
</div> </div>
<div class="logon" @click="loginMobile" v-if="current !== 0"></div> <div class="logon" @click="loginMobile" v-if="current !== 0"></div>
<div class="logon" @click="submit" v-if="current === 0"></div> <div class="logon" @click="submit" v-if="current === 0"></div>
<div class="tips"> <div class="tips">
<div @click="jumpRegister"></div> <div @click="jumpRegister"></div>
<div @click="jumpRetrievePassword"></div>
<div v-if="current==0" @click="current = 1"></div> <div v-if="current==0" @click="current = 1"></div>
<div v-if="current==1" @click="current = 0"></div> <div v-if="current==1" @click="current = 0"></div>
</div> </div>
@ -95,182 +89,17 @@
mobile: "", mobile: "",
password: "", password: "",
captcha: "", captcha: "",
formItem: 1,
type: "login", type: "login",
logoUrl: "", logoUrl: "",
keyCode: "",
codeUrl: "",
codeVal: "",
isShowCode: false,
platform: '',
appLoginStatus: false, //
appUserInfo: null, //
appleLoginStatus: false, //
appleUserInfo: null,
appleShow: false // ios13
}; };
}, },
watch:{
formItem:function(nval,oVal){
if(nval == 1){
this.type = 'login'
}else{
this.type = 'register'
}
}
},
mounted: function() { mounted: function() {
this.getCode();
this.getLogoImage(); this.getLogoImage();
}, },
onLoad() { onLoad() {
let self = this
uni.getSystemInfo({
success: function(res) {
if (res.platform.toLowerCase() == 'ios' && res.system.split(' ')[1] >= 13) {
self.appleShow = true
}
}
});
}, },
methods: { methods: {
//
appleLogin() {
let self = this
this.mobile = ''
this.captcha = ''
uni.showLoading({
title: '登录中'
})
uni.login({
provider: 'apple',
timeout: 10000,
success(loginRes) {
uni.getUserInfo({
provider: 'apple',
success: function(infoRes) {
self.appleUserInfo = infoRes.userInfo
self.appleLoginApi()
},
fail() {
uni.hideLoading()
uni.showToast({
title: '获取用户信息失败',
icon: 'none',
duration: 2000
})
},
complete() {
uni.hideLoading()
}
});
},
fail(error) {
uni.hideLoading()
console.log(error)
}
})
},
// Api
appleLoginApi() {
let self = this
appleLogin({
openId: self.appleUserInfo.openId,
email: self.appleUserInfo.email == undefined ? '' :self.appleUserInfo.email,
identityToken: self.appleUserInfo.identityToken || ''
}).then((res) => {
this.$store.commit("LOGIN", {
'token': res.data.token
});
this.getUserInfo(res.data);
}).catch(error => {
uni.hideLoading();
uni.showModal({
title: '提示',
content: `错误信息${error}`,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
})
},
// App
wxLogin() {
let self = this
this.mobile = ''
this.captcha = ''
uni.showLoading({
title: '登录中'
})
uni.login({
provider: 'weixin',
success: function(loginRes) {
//
uni.getUserInfo({
provider: 'weixin',
success: function(infoRes) {
uni.hideLoading();
self.appUserInfo = infoRes.userInfo
self.appUserInfo.type = self.platform === 'ios' ? 'iosWx' : 'androidWx'
self.wxLoginGo(self.appUserInfo)
},
fail() {
uni.hideLoading();
uni.showToast({
title: '获取用户信息失败',
icon: 'none',
duration: 2000
})
},
complete() {
uni.hideLoading()
}
});
},
fail() {
uni.hideLoading()
uni.showToast({
title: '登录失败',
icon: 'none',
duration: 2000
})
}
});
},
wxLoginGo(userInfo) {
appAuth(userInfo).then(res => {
if (res.data.type === 'register') {
uni.navigateTo({
url: '/pages/users/app_login/index?authKey='+res.data.key
})
}
if (res.data.type === 'login') {
this.$store.commit("LOGIN", {
'token': res.data.token
});
this.getUserInfo(res.data);
}
}).catch(res => {
that.$util.Tips({
title: res
});
});
},
again() {
this.codeUrl =
VUE_APP_API_URL +
"/sms_captcha?" +
"key=" +
this.keyCode +
Date.parse(new Date());
},
getCode() {
let that = this
},
async getLogoImage() { async getLogoImage() {
let that = this; let that = this;
getLogo().then(res => { getLogo().then(res => {
@ -300,7 +129,8 @@
let data = res.data; let data = res.data;
let newTime = Math.round(new Date() / 1000); let newTime = Math.round(new Date() / 1000);
this.$store.commit("LOGIN", { this.$store.commit("LOGIN", {
'token': res.data.token 'token': res.data.accessToken,
'refreshToken': res.data.refreshToken
}); });
that.getUserInfo(data); that.getUserInfo(data);
}) })
@ -353,6 +183,11 @@
uni.navigateTo({ uni.navigateTo({
url: '/pages/users/register/index' url: '/pages/users/register/index'
}) })
},
jumpRetrievePassword(){
uni.navigateTo({
url: '/pages/users/retrievePassword/index'
})
}, },
async code() { async code() {
let that = this; let that = this;
@ -362,8 +197,7 @@
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.mobile)) return that.$util.Tips({ if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.mobile)) return that.$util.Tips({
title: '请输入正确的手机号码' title: '请输入正确的手机号码'
}); });
if (that.formItem == 2) that.type = "register"; await registerVerify(that.mobile, 1)
await registerVerify(that.mobile)
.then(res => { .then(res => {
that.$util.Tips({title:res.message}); that.$util.Tips({title:res.message});
that.sendCode(); that.sendCode();
@ -397,7 +231,8 @@
data data
}) => { }) => {
this.$store.commit("LOGIN", { this.$store.commit("LOGIN", {
'token': data.token 'token': data.accessToken,
'refreshToken': data.refreshToken
}); });
that.getUserInfo(data); that.getUserInfo(data);
}) })
@ -408,10 +243,11 @@
}); });
}, },
getUserInfo(data){ getUserInfo(data){
this.$store.commit("SETUID", data.uid); this.$store.commit("SETUID", data.userId);
getUserInfo().then(res => { getUserInfo().then(res => {
this.$store.commit("UPDATE_USERINFO", res.data); this.$store.commit("UPDATE_USERINFO", res.data);
let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index"; // let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
let backUrl = "/pages/index/index";
if (backUrl.indexOf('/pages/users/login/index') !== -1) { if (backUrl.indexOf('/pages/users/login/index') !== -1) {
backUrl = '/pages/index/index'; backUrl = '/pages/index/index';
} }

View File

@ -81,7 +81,7 @@
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.registerForm.mobile)) return this.$util.Tips({ if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(this.registerForm.mobile)) return this.$util.Tips({
title: '请输入正确的手机号码' title: '请输入正确的手机号码'
}); });
await registerVerify(this.registerForm.mobile) await registerVerify(this.registerForm.mobile, 4)
.then(res => { .then(res => {
this.$util.Tips({ this.$util.Tips({
title: res.message title: res.message

View File

@ -72,7 +72,7 @@
}, },
mixins: [sendVerifyCode], mixins: [sendVerifyCode],
mounted: function() { mounted: function() {
this.getCode();
}, },
methods: { methods: {
back() { back() {
@ -82,15 +82,6 @@
this.codeUrl = this.codeUrl =
VUE_APP_API_URL + "/captcha?" + this.keyCode + Date.parse(new Date()); VUE_APP_API_URL + "/captcha?" + this.keyCode + Date.parse(new Date());
}, },
getCode() {
getCodeApi()
.then(res => {
this.keyCode = res.data.key;
})
.catch(res => {
this.$dialog.error(res.msg);
});
},
async registerReset() { async registerReset() {
var that = this; var that = this;
if (!that.account) return that.$util.Tips({ if (!that.account) return that.$util.Tips({
@ -103,10 +94,9 @@
title: '请填写验证码' title: '请填写验证码'
}); });
registerReset({ registerReset({
account: that.account, mobile: that.account,
captcha: that.captcha,
password: that.password, password: that.password,
code: that.codeVal code: that.captcha
}) })
.then(res => { .then(res => {
that.$util.Tips({ that.$util.Tips({
@ -129,15 +119,9 @@
if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({ if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
title: '请输入正确的手机号码' title: '请输入正确的手机号码'
}); });
if (that.formItem == 2) that.type = "register"; await registerVerify(that.account, 3)
await registerVerify({
phone: that.account,
type: that.type,
key: that.keyCode,
code: that.codeVal
})
.then(res => { .then(res => {
that.$dialog.success(res.message); // that.$dialog.success(res.message);
that.sendCode(); that.sendCode();
}) })
.catch(res => { .catch(res => {

View File

@ -158,8 +158,8 @@
initialize: function() { initialize: function() {
let that = this,province = [],city = [],area = []; let that = this,province = [],city = [],area = [];
if (that.district.length) { if (that.district.length) {
let cityChildren = that.district[0].child || []; let cityChildren = that.district[0].children || [];
let areaChildren = cityChildren.length ? (cityChildren[0].child || []) : []; let areaChildren = cityChildren.length ? (cityChildren[0].children || []) : [];
that.district.forEach(function(item) { that.district.forEach(function(item) {
province.push(item.name); province.push(item.name);
}); });
@ -175,9 +175,9 @@
bindRegionChange: function(e) { bindRegionChange: function(e) {
let multiIndex = this.multiIndex, let multiIndex = this.multiIndex,
province = this.district[multiIndex[0]] || { province = this.district[multiIndex[0]] || {
child: [] children: []
}, },
city = province.child[multiIndex[1]] || { city = province.children[multiIndex[1]] || {
cityId: 0 cityId: 0
}, },
multiArray = this.multiArray, multiArray = this.multiArray,
@ -193,25 +193,25 @@
column = e.detail.column, column = e.detail.column,
value = e.detail.value, value = e.detail.value,
currentCity = this.district[value] || { currentCity = this.district[value] || {
child: [] children: []
}, },
multiArray = that.multiArray, multiArray = that.multiArray,
multiIndex = that.multiIndex; multiIndex = that.multiIndex;
multiIndex[column] = value; multiIndex[column] = value;
switch (column) { switch (column) {
case 0: case 0:
let areaList = currentCity.child[0] || { let areaList = currentCity.children[0] || {
child: [] children: []
}; };
multiArray[1] = currentCity.child.map((item) => { multiArray[1] = currentCity.children.map((item) => {
return item.name; return item.name;
}); });
multiArray[2] = areaList.child.map((item) => { multiArray[2] = areaList.children.map((item) => {
return item.name; return item.name;
}); });
break; break;
case 1: case 1:
let cityList = that.district[multiIndex[0]].child[multiIndex[1]].child || []; let cityList = that.district[multiIndex[0]].children[multiIndex[1]].children || [];
multiArray[2] = cityList.map((item) => { multiArray[2] = cityList.map((item) => {
return item.name; return item.name;
}); });

View File

@ -252,8 +252,8 @@
that.loading = true; that.loading = true;
that.loadTitle = ''; that.loadTitle = '';
getAddressList({ getAddressList({
page: that.page, pageNo: that.page,
limit: that.limit pageSize: that.limit
}).then(res => { }).then(res => {
let list = res.data.list; let list = res.data.list;
let loadend = list.length < that.limit; let loadend = list.length < that.limit;

View File

@ -74,7 +74,8 @@
<script> <script>
import { import {
userEdit, userEdit,
getLogout getLogout,
uploadAvatar
} from '@/api/user.js'; } from '@/api/user.js';
import { import {
switchH5Login switchH5Login
@ -162,12 +163,9 @@
uploadpic: function() { uploadpic: function() {
let that = this; let that = this;
that.$util.uploadImageOne({ that.$util.uploadImageOne({
url: 'user/upload/image', name: 'file',
name: 'multipart',
model: "maintain",
pid: 0
}, function(res) { }, function(res) {
that.newAvatar = res.data.url; that.newAvatar = res.data;
}); });
}, },

View File

@ -3,6 +3,7 @@ import {
} from "../../api/user.js"; } from "../../api/user.js";
import { import {
LOGIN_STATUS, LOGIN_STATUS,
REFRESH_TOKEN,
UID, UID,
PLATFORM PLATFORM
} from '../../config/cache'; } from '../../config/cache';
@ -13,6 +14,7 @@ import {
const state = { const state = {
token: Cache.get(LOGIN_STATUS) || '', token: Cache.get(LOGIN_STATUS) || '',
refreshToken: Cache.get(REFRESH_TOKEN) || '',
backgroundColor: "#fff", backgroundColor: "#fff",
userInfo: Cache.get(USER_INFO)?JSON.parse(Cache.get(USER_INFO)):null, userInfo: Cache.get(USER_INFO)?JSON.parse(Cache.get(USER_INFO)):null,
uid: Cache.get(UID) || null, uid: Cache.get(UID) || null,
@ -25,7 +27,9 @@ const state = {
const mutations = { const mutations = {
LOGIN(state, opt) { LOGIN(state, opt) {
state.token = opt.token; state.token = opt.token;
state.refreshToken = opt.refreshToken;
Cache.set(LOGIN_STATUS, opt.token); Cache.set(LOGIN_STATUS, opt.token);
Cache.set(REFRESH_TOKEN, opt.refreshToken);
}, },
SETUID(state,val){ SETUID(state,val){
state.uid = val; state.uid = val;
@ -38,6 +42,7 @@ const mutations = {
state.token = undefined; state.token = undefined;
state.uid = undefined state.uid = undefined
Cache.clear(LOGIN_STATUS); Cache.clear(LOGIN_STATUS);
Cache.clear(REFRESH_TOKEN);
Cache.clear(UID); Cache.clear(UID);
Cache.clear(USER_INFO); Cache.clear(USER_INFO);
}, },

View File

@ -32,7 +32,7 @@ function baseRequest(url, method, data, {
}); });
} }
} }
if (store.state.app.token) header[TOKENNAME] = store.state.app.token; if (store.state.app.token) header[TOKENNAME] = 'Bearer ' + store.state.app.token;
return new Promise((reslove, reject) => { return new Promise((reslove, reject) => {
uni.request({ uni.request({
url: Url + '/app-api/' + url, url: Url + '/app-api/' + url,

View File

@ -440,7 +440,7 @@ export default {
sourceType = opt.sourceType || ['album', 'camera'], sourceType = opt.sourceType || ['album', 'camera'],
is_load = opt.is_load || true, is_load = opt.is_load || true,
uploadUrl = opt.url || '', uploadUrl = opt.url || '',
inputName = opt.name || 'pics', inputName = opt.name || 'file',
pid = opt.pid, pid = opt.pid,
model = opt.model; model = opt.model;
@ -453,7 +453,7 @@ export default {
uni.showLoading({ uni.showLoading({
title: '图片上传中', title: '图片上传中',
}); });
let urlPath = HTTP_ADMIN_URL + '/api/admin/upload/image' + "?model=" + model + "&pid=" + pid let urlPath = HTTP_ADMIN_URL + '/app-api/infra/file/upload'
let localPath = res.tempFilePaths[0]; let localPath = res.tempFilePaths[0];
uni.uploadFile({ uni.uploadFile({
url: urlPath, url: urlPath,
@ -464,9 +464,11 @@ export default {
// #ifdef MP // #ifdef MP
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
// #endif // #endif
[TOKENNAME]: store.state.app.token [TOKENNAME]: store.state.app.token,
'tenant-id': 1
}, },
success: function(res) { success: function(res) {
console.log('res', res)
uni.hideLoading(); uni.hideLoading();
if (res.statusCode == 403) { if (res.statusCode == 403) {
that.Tips({ that.Tips({
@ -474,8 +476,7 @@ export default {
}); });
} else { } else {
let data = res.data ? JSON.parse(res.data) : {}; let data = res.data ? JSON.parse(res.data) : {};
if (data.code == 200) { if (data.code == 0) {
data.data.localPath = localPath;
successCallback && successCallback(data) successCallback && successCallback(data)
} else { } else {
errorCallback && errorCallback(data); errorCallback && errorCallback(data);