Browse Source

首页交互

master
kuaileWu 1 year ago
parent
commit
1eb86d9000
  1. 21
      App.vue
  2. 107
      main.js
  3. 15
      manifest.json
  4. 53
      pages/index/index.vue
  5. 6
      pages/user_modify/user_modify.vue

21
App.vue

@ -1,6 +1,25 @@
<script>
export default {
onLaunch: function() {},
globalData:{
doctorId:'',
doctoridStorageKey:'doctor_id'
},
onLaunch: function(option) {
if(!(option.query && option.query.did)){
var doctor_id = uni.getStorageSync(this.globalData.doctoridStorageKey)
if(doctor_id){
this.globalData.doctorId = doctor_id
}else{
document.getElementsByTagName('body')[0].innerHTML = ""
setTimeout(function(){
alert('请扫描二维码或点击分享网站链接进入');
},500)
}
}else{
this.globalData.doctorId = option.query.did
uni.setStorageSync(this.globalData.doctoridStorageKey, this.globalData.doctorId)
}
},
onShow: function() {},
onHide: function() {}
}

107
main.js

@ -22,10 +22,10 @@ const NODE_ENV = 'development';
// const NODE_ENV = 'production';
if(NODE_ENV == 'development'){
Vue.prototype.cssUrl = '/static/images/frontend/';
Vue.prototype.request_domain = "http://xmztest.yitongtang66.com/";
Vue.prototype.request_domain = "http://apizj.checkcopy.com/";
}else{
Vue.prototype.cssUrl = 'https://xmz.yitongtang66.com/assets/img/new/';
Vue.prototype.request_domain = "https://xmz.yitongtang66.com/";
Vue.prototype.cssUrl = '/static/images/frontend/';
Vue.prototype.request_domain = "http://apizj.checkcopy.com/";
}
try{
@ -173,9 +173,9 @@ if(Vue.prototype.provider == Vue.prototype.provider_weixin) {
Vue.prototype.View = currentPageView+'New';
}
const CODE_SUCCESS = 200;
const CODE_SUCCESS = 2000;
const CODE_ERROR = 40001;
const CODE_LOGIN_EXIPRE = 40002;
const CODE_LOGIN_EXIPRE = 4000;
Vue.prototype.user_preview = 1;
Vue.prototype.edit_preview = 2;
@ -184,49 +184,34 @@ Vue.prototype.edit_album = 4;
function removeLogin() {
uni.removeStorageSync('token');
uni.removeStorageSync('uuid');
uni.removeStorageSync('nickname');
uni.removeStorageSync('avatar');
uni.removeStorageSync('level_id');
uni.removeStorageSync('level_name');
uni.removeStorageSync('is_admin');
uni.removeStorageSync('avatar_full');
uni.removeStorageSync('create');
uni.removeStorageSync('uuid_str');
}
function req(url, data={}, method = 'POST') {
var domain = Vue.prototype.request_domain;
data.xcxtype = 3;
if(Vue.prototype.appid != '') {
data.appid = Vue.prototype.appid;
data.xcx_scource = Vue.prototype.USER_SOURCE_WX_XCX;
function req(url, data={}, method = 'POST', header={}) {
var domain = Vue.prototype.request_domain;
if(Vue.prototype.appid != '') {
data.appid = Vue.prototype.appid;
data.xcx_scource = Vue.prototype.USER_SOURCE_WX_XCX;
}else{
domain = '/api/';
if(Vue.prototype.isMobile){
data.xcx_scource = Vue.prototype.USER_SOURCE_H5;
domain = '/api/';
if(Vue.prototype.isMobile){
data.xcx_scource = Vue.prototype.USER_SOURCE_H5;
if(Vue.prototype.env_val.indexOf('weixin') > -1) data.xcx_scource = Vue.prototype.USER_SOURCE_WX_H5;
data.host = location.host;
}else{
}else{
data.xcx_scource = Vue.prototype.USER_SOURCE_PC;
data.host = location.host;
}
}
}
if(NODE_ENV == 'development') data.env = 'dev';
var headerObj = {'content-type': 'application/x-www-form-urlencoded'};
var token = uni.getStorageSync('token');
var uuid = uni.getStorageSync('uuid');
var loginFunc = '';
if(data.xcx_scource == Vue.prototype.USER_SOURCE_WX_XCX) loginFunc = 'ai_xcx_login';
data.submit_source = data.xcx_scource;
data.is_ai = 1;
if(token && uuid && url != loginFunc){
data.token = token;
data.user_id = uuid;
}
var noNeedLoginFunc = [
'client/common/mp/config',
'client/user/login'
]
var isNeedLogin = !noNeedLoginFunc.includes(url);
var headerObj = {'content-type': 'application/x-www-form-urlencoded'};
var token = uni.getStorageSync('token');
if(token) headerObj.Authorization = token
var getWxH5LoginConfigUri = 'client/common/mp/config'
return new Promise((resolve, reject) => {
uni.request({
@ -239,30 +224,22 @@ function req(url, data={}, method = 'POST') {
try{
var rdata = res.data;
if(rdata.code != CODE_SUCCESS) {
if(data.xcx_scource == Vue.prototype.USER_SOURCE_WX_XCX && !data.repeat && rdata.code==CODE_LOGIN_EXIPRE && url != 'userapi/login2/weChatLogin'){
if(rdata.code==CODE_LOGIN_EXIPRE && data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5 && url != getWxH5LoginConfigUri && data.repeat != 1){
if(headerObj.Authorization) {
console.log(headerObj.Authorization, url)
return
}
removeLogin();
xcx_login(url, data, method).then(data=>{
return resolve(data);
});
return;
}
if(data.xcx_scource == Vue.prototype.USER_SOURCE_H5 && res.data.info.indexOf('请先登录')>-1){
location.href="/pages/jumpxcx/jumpxcx";
return;
}
if(rdata.code==CODE_LOGIN_EXIPRE && data.xcx_scource == Vue.prototype.USER_SOURCE_WX_H5 && url != 'ai_get_mplogin_url'){
var logindatac = new Object();
logindatac.host = location.host;
const pagesc = getCurrentPages();
const currentPagec = pagesc[pagesc.length - 1];
var pageUrlc = '/'+currentPagec.route;
logindatac.state = encodeURIComponent(pageUrlc);
req('ai_get_mplogin_url', logindatac).then(data=>{
if(data == -1 || !data.login_link) return;
location.href = data.login_link;
var pageUrlc = '/'+currentPagec.route;
uni.setStorageSync('rebackPagePath', pageUrlc);
req(getWxH5LoginConfigUri, logindatac, 'GET').then(data=>{
if(data == -1 || !data.user_authorize_url) return;
location.href = data.user_authorize_url;
});
return;
}
@ -325,18 +302,8 @@ function xcx_login(url, eqdata={}, method = 'POST') {
if (res.code) {
var pdata = new Object();
pdata.code = res.code;
req('userapi/login2/weChatLogin', pdata).then(data=>{
req('client/user/login', pdata, 'POST').then(data=>{
uni.setStorageSync('token', data.token);
uni.setStorageSync('uuid', data.userId);
uni.setStorageSync('uuid_str', data.userIdStr);
uni.setStorageSync('nickname', data.nickname);
uni.setStorageSync('avatar', data.avatar);
uni.setStorageSync('level_id', data.level_id);
uni.setStorageSync('level_name', data.level_name);
uni.setStorageSync('avatar_full', data.avatar_full);
uni.setStorageSync('create', data.create);
if(data.is_admin) uni.setStorageSync('is_admin', data.is_admin);
eqdata.repeat = 1;
req(url, eqdata, method).then(data=>{
return resolve(data);

15
manifest.json

@ -69,14 +69,23 @@
"uniStatistics" : {
"enable" : false
},
"vueVersion" : "2",
"vueVersion" : "2",
"h5" : {
"router" : {
"mode" : "history"
"mode" : "history",
"base" : "/"
},
"devServer" : {
"port" : 80,
"disableHostCheck" : true
"disableHostCheck" : true,
"proxy" : {
"/api" : {
"target" : "http://apizj.checkcopy.com",
"changeOrigin" : true,
"secure" : false
}
}
},
"optimization" : {
"treeShaking" : {

53
pages/index/index.vue

@ -1,5 +1,5 @@
<template>
<view class="index-page btPadding">
<view class="index-page btPadding" v-if="pageShow">
<view class="header-wrapper flex">
<view class="left">
<view class="flex top PfScMedium">
@ -131,18 +131,57 @@
export default {
data() {
return {
cssUrl:this.cssUrl
cssUrl:this.cssUrl,
code:'',
pageShow:false,
doctor_id:''
}
},
onLoad() {
uni.setNavigationBarTitle({
title:'李静医生预约就诊'
});
},
components:{
tabbar:tabbar
},
onLoad(option) {
if(option.code) this.code = option.code
},
onShow() {
this.doctor_id = getApp().globalData.doctorId
if(!this.doctor_id) return;
var title = '李静医生预约就诊'
if(this.code) title = '登录'
uni.setNavigationBarTitle({
title:title
})
var token = uni.getStorageSync('token')
if(this.code && !token) {
var rebackPagePath = uni.getStorageSync('rebackPagePath')
this.login()
return
}
this.getDoctorInfo()
},
methods: {
login() {
this.$http.req('client/user/login', {code:this.code}, 'POST').then(data=>{
if(data == -1) return
uni.setStorageSync('token', data.token)
var rebackPagePath = uni.getStorageSync('rebackPagePath')
if(rebackPagePath){
uni.navigateTo({
url:rebackPagePath
})
}
});
},
getDoctorInfo() {
this.$http.req('client/user/doctorpage/2', {}, 'GET').then(data=>{
if(data == -1) return
this.pageShow = true
this.keywords = data
});
},
enlargePicture(imgUrl) {
var list = new Array();
list[0] = imgUrl;

6
pages/user_modify/user_modify.vue

@ -1,5 +1,6 @@
<template>
<view class="page-user-modify">
<view class="page-user-modify">
<view class="top"></view>
<view class="item-box btPadding">
<view class="item">
<view class="left PfScMedium">头像</view>
@ -81,6 +82,9 @@
<style lang="scss" scoped>
.page-user-modify{
.top{
margin-top: 20rpx;
}
background: #F8F8F8;
width: 100%;
height: 100vh;

Loading…
Cancel
Save