diff --git a/App.vue b/App.vue
index 6d9476b..560adf0 100644
--- a/App.vue
+++ b/App.vue
@@ -17,4 +17,10 @@ export default {
diff --git a/common/index.js b/common/index.js
new file mode 100644
index 0000000..22c8943
--- /dev/null
+++ b/common/index.js
@@ -0,0 +1,100 @@
+/**
+ * 通用消息框
+ * @param content string 消息内容
+ * @param fn function 回调
+ *
+ */
+const msgToast = (content, fn, type = "none") => {
+ uni.showToast({
+ title: content,
+ duration: 2000,
+ icon: type,
+ success: fn
+ ? () => {
+ setTimeout(() => {
+ fn();
+ }, 1500);
+ }
+ : function () {},
+ });
+};
+
+/* 手机号验证 */
+const vefTel = (key) => {
+ let reg_tel =
+ /^1(3[0-9]|4[01456879]|5[0-35-9]|6[2567]|7[0-8]|8[0-9]|9[0-35-9])\d{8}$/;
+ ///^(((13[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[3-8]{1})|(18[0-9]{1})|(19[0-9]{1})|(14[5-7]{1}))+\d{8})$/; // 11位手机号
+ if (key === "" || key === undefined || key === null) {
+ uni.showToast({
+ title: "请输入手机号",
+ duration: 2000,
+ icon: "none",
+ });
+ return false;
+ } else if (!reg_tel.test(key)) {
+ uni.showToast({
+ title: "手机号码格式不正确",
+ duration: 2000,
+ icon: "none",
+ });
+ return false;
+ } else {
+ return true;
+ }
+};
+
+/* 非空验证 */
+const vefEmpty = (key, msg) => {
+ if (key === "" || key === undefined || key === null) {
+ uni.showToast({
+ title: msg,
+ duration: 2000,
+ icon: "none",
+ });
+ return false;
+ } else {
+ return true;
+ }
+};
+
+const logout = () => {
+ msgToast("登录已过期,请重新登录", () => {
+ uni.removeStorageSync("userInfo");
+ uni.reLaunch({
+ url: "../login/login",
+ });
+ });
+};
+/**
+ * @description: H5 App通用方案 解决H5刷新返回失败问题
+ * @param {*} params
+ */
+const navigateBack = (params) => {
+ const pages = getCurrentPages();
+ if (pages.length === 1) {
+ if (typeof params === "number") {
+ history.go(-params);
+ } else {
+ history.back();
+ }
+ } else {
+ uni.navigateBack();
+ }
+};
+/**
+ * @description: 获取url参数
+ * @param {*} params
+ */
+const getLocationParams = (name) => {
+ const pages = getCurrentPages();
+ const curPage = pages[pages.length - 1];
+ return name ? curPage.options[name] : curPage.options;
+};
+export default {
+ msgToast,
+ vefTel,
+ vefEmpty,
+ logout,
+ navigateBack,
+ getLocationParams,
+};
diff --git a/http/index.js b/http/index.js
new file mode 100644
index 0000000..27ddd06
--- /dev/null
+++ b/http/index.js
@@ -0,0 +1,4 @@
+import login from "./login";
+export default {
+ login,
+};
diff --git a/http/interface.js b/http/interface.js
new file mode 100644
index 0000000..1283304
--- /dev/null
+++ b/http/interface.js
@@ -0,0 +1,170 @@
+/**
+ * 通用uni-app网络请求
+ * 基于 Promise 对象实现更简单的 request 使用方式,支持请求和响应拦截
+ */
+export default {
+ config: {
+ baseUrl: "",
+ header: {
+ "Content-Type": "application/json;charset=UTF-8",
+ // 'Content-Type':'application/x-www-form-urlencoded'
+ },
+ data: {},
+ method: "GET",
+ dataType: "json" /* 如设为json,会对返回的数据做一次 JSON.parse */,
+ responseType: "text",
+ success() {},
+ fail() {},
+ complete() {},
+ },
+ interceptor: {
+ request: null,
+ response: null,
+ },
+ request(options) {
+ if (!options) {
+ options = {};
+ }
+ options.baseUrl = options.baseUrl || this.config.baseUrl;
+ options.dataType = options.dataType || this.config.dataType;
+ options.url = options.baseUrl + options.url;
+ options.data = options.data || {};
+ options.method = options.method || this.config.method;
+ //TODO 加密数据
+ options.header = options.header || this.config.header;
+ //TODO 数据签名
+ let _token = {
+ Authorization: uni.getStorageSync("token") || "undefined",
+ };
+ options.header = Object.assign({}, options.header, _token);
+ /*
+
+ _sign = {'sign': sign(JSON.stringify(options.data))}
+ options.header = Object.assign({}, options.header, _token,_sign)
+ */
+
+ return new Promise((resolve, reject) => {
+ let _config = null;
+
+ options.complete = (response) => {
+ let statusCode = response.statusCode;
+ response.config = _config;
+ if (process.env.NODE_ENV === "development") {
+ if (statusCode === 200) {
+ // console.log("【" + _config.requestId + "】 结果:" + JSON.stringify(response.data))
+ }
+ }
+ if (this.interceptor.response) {
+ let newResponse = this.interceptor.response(response);
+ if (newResponse) {
+ response = newResponse;
+ }
+ }
+ if (response.data.status === 401) {
+ let curPage = getCurrentPages();
+ let route = curPage[curPage.length - 1].route; //获取当前页面的路由
+ if (route !== "pages/login/login") {
+ uni.navigateTo({
+ url: "/pages/login/login",
+ });
+ }
+ }
+ // 统一的响应日志记录
+ _reslog(response);
+ if (statusCode === 200) {
+ //成功
+ resolve(response.data);
+ } else {
+ reject(response);
+ }
+ };
+
+ _config = Object.assign({}, this.config, options);
+ _config.requestId = new Date().getTime();
+
+ if (this.interceptor.request) {
+ this.interceptor.request(_config);
+ }
+
+ // 统一的请求日志记录
+ _reqlog(_config);
+
+ uni.request(_config);
+ });
+ },
+ get(url, data, options) {
+ if (!options) {
+ options = {};
+ }
+ options.url = url;
+ options.data = data;
+ options.method = "GET";
+ return this.request(options);
+ },
+ post(url, data, options, header) {
+ if (!options) {
+ options = {};
+ }
+ options.url = url;
+ options.data = data;
+ options.header = header;
+ options.method = "POST";
+ return this.request(options);
+ },
+ put(url, data, options) {
+ if (!options) {
+ options = {};
+ }
+ options.url = url;
+ options.data = data;
+ options.method = "PUT";
+ return this.request(options);
+ },
+ delete(url, data, options) {
+ if (!options) {
+ options = {};
+ }
+ options.url = url;
+ options.data = data;
+ options.method = "DELETE";
+ return this.request(options);
+ },
+};
+
+/**
+ * 请求接口日志记录
+ */
+function _reqlog(req) {
+ if (process.env.NODE_ENV === "development") {
+ // console.log("【" + req.requestId + "】 地址:" + req.url)
+ if (req.data) {
+ // console.log("【" + req.requestId + "】 请求参数:" + JSON.stringify(req.data))
+ }
+ }
+ //TODO 调接口异步写入日志数据库
+}
+
+/**
+ * 响应接口日志记录
+ */
+function _reslog(res) {
+ let _statusCode = res.statusCode;
+ if (process.env.NODE_ENV === "development") {
+ // console.log("【" + res.config.requestId + "】 地址:" + res.config.url)
+ if (res.config.data) {
+ // console.log("【" + res.config.requestId + "】 请求参数:" + JSON.stringify(res.config.data))
+ }
+ // console.log("【" + res.config.requestId + "】 响应结果:" + JSON.stringify(res))
+ }
+ //TODO 除了接口服务错误外,其他日志调接口异步写入日志数据库
+ switch (_statusCode) {
+ case 200:
+ break;
+ case 401:
+ break;
+ case 404:
+ break;
+ default:
+ break;
+ }
+}
diff --git a/http/login.js b/http/login.js
new file mode 100644
index 0000000..7a02a43
--- /dev/null
+++ b/http/login.js
@@ -0,0 +1,5 @@
+import http from "./interface";
+
+// 登录
+
+export default {};
diff --git a/main.js b/main.js
index 3f9b473..a7f556f 100644
--- a/main.js
+++ b/main.js
@@ -1,24 +1,28 @@
-import App from './App'
+import App from "./App";
// #ifndef VUE3
-import Vue from 'vue'
-import './uni.promisify.adaptor'
-Vue.config.productionTip = false
-App.mpType = 'app'
-import uView from './uview-ui'
-Vue.use(uView)
+import Vue from "vue";
+import api from "@/http/";
+import common from "./common/index.js";
+import "./uni.promisify.adaptor";
+Vue.config.productionTip = false;
+App.mpType = "app";
+import uView from "./uview-ui";
+Vue.use(uView);
+Vue.prototype.$api = api;
+Vue.prototype.$common = common;
const app = new Vue({
- ...App
-})
-app.$mount()
+ ...App,
+});
+app.$mount();
// #endif
// #ifdef VUE3
-import { createSSRApp } from 'vue'
+import { createSSRApp } from "vue";
export function createApp() {
- const app = createSSRApp(App)
+ const app = createSSRApp(App);
return {
- app
- }
+ app,
+ };
}
// #endif
diff --git a/pages.json b/pages.json
index 165e174..987134d 100644
--- a/pages.json
+++ b/pages.json
@@ -2,7 +2,47 @@
"easycom": {
"^u-(.*)": "@/uview-ui/components/u-$1/u-$1.vue"
},
- "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
+ "pages": [
+ {
+ "path": "pages/login/login",
+ "style": {
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false,
+ "app-plus": {
+ "titleNView": false // 禁用原生导航
+ }
+ }
+ },
+ {
+ "path": "pages/register/register",
+ "style": {
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false,
+ "app-plus": {
+ "titleNView": false // 禁用原生导航
+ }
+ }
+ },
+ {
+ "path": "pages/realName/realName",
+ "style": {
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false,
+ "app-plus": {
+ "titleNView": false // 禁用原生导航
+ }
+ }
+ },
+ {
+ "path": "pages/cameraContext/cameraContext",
+ "style": {
+ "navigationBarTitleText": "",
+ "enablePullDownRefresh": false,
+ "app-plus": {
+ "titleNView": false // 禁用原生导航
+ }
+ }
+ },
{
"path": "pages/home/index",
"style": {
@@ -24,16 +64,7 @@
"enablePullDownRefresh": false
}
},
- {
- "path": "pages/login/login",
- "style": {
- "navigationBarTitleText": "",
- "enablePullDownRefresh": false,
- "app-plus": {
- "titleNView": false // 禁用原生导航
- }
- }
- },
+
{
"path": "pages/mine/index",
diff --git a/pages/cameraContext/cameraContext.vue b/pages/cameraContext/cameraContext.vue
new file mode 100644
index 0000000..63ff5b8
--- /dev/null
+++ b/pages/cameraContext/cameraContext.vue
@@ -0,0 +1,10 @@
+
+ 23
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 4168472..dba0735 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -31,25 +31,68 @@ export default {
});
if (res.status == 0) {
uni.setStorageSync("token", res.data.token);
- // uni.redirectTo({
- // url: "../home/index"
- // });
+ uni.redirectTo({
+ url: "/pages/register/register"
+ });
}
} else {
this.$common.msgToast("请不要拒绝哟~重新点击登录");
}
+ },
+ async login() {
+ // 获取code
+ uni.login({
+ provider: "weixin",
+ success: async res => {
+ this.code = res.code;
+ let res1 = await this.$api.user.loginToken({ wxLoginCode: res.code });
+ if (res1.status == 0) {
+ if (res1.data.code == 2) {
+ this.isShow = true;
+ this.openId = res1.data.openid;
+ } else {
+ uni.setStorageSync("token", res1.data.token);
+ uni.redirectTo({
+ url: "/pages/register/register"
+ });
+ }
+ } else {
+ this.$common.msgToast(res1.msg);
+ }
+ }
+ });
+ }
+ },
+ onLoad() {
+ this.isLogoutShow = true;
+ if (!this.isLogoutShow) {
+ // 获取code
+ uni.login({
+ provider: "weixin",
+ success: async res => {
+ this.code = res.code;
+ let res1 = await this.$api.user.loginToken({ wxLoginCode: res.code });
+ if (res1.status == 0) {
+ if (res1.data.code == 2) {
+ this.isShow = true;
+ this.openId = res1.data.openid;
+ } else {
+ uni.setStorageSync("token", res1.data.token);
+ uni.redirectTo({
+ url: "/pages/register/register"
+ });
+ }
+ } else {
+ this.$common.msgToast(res1.msg);
+ }
+ }
+ });
}
}
};
\ No newline at end of file
diff --git a/pages/register/register.vue b/pages/register/register.vue
new file mode 100644
index 0000000..97badb4
--- /dev/null
+++ b/pages/register/register.vue
@@ -0,0 +1,159 @@
+
+
+
+
+
+
+
+ 注册手机号
+
+
+ 手机号
+
+
+
+ 确定手机号
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/static/image/card.png b/static/image/card.png
new file mode 100644
index 0000000..8c220cb
Binary files /dev/null and b/static/image/card.png differ
diff --git a/static/image/card2.png b/static/image/card2.png
new file mode 100644
index 0000000..be17ac2
Binary files /dev/null and b/static/image/card2.png differ
diff --git a/static/image/logo2.png b/static/image/logo2.png
new file mode 100644
index 0000000..0808669
Binary files /dev/null and b/static/image/logo2.png differ