main
xy 2 years ago
parent 672da25b2e
commit 34734cb1c4

@ -1,7 +1,30 @@
<script>
export default {
onLaunch: function() {
console.log('App Launch')
// let link = window.location.href;
// if (/code=/.test(link) || link.indexOf("code") > -1) {
// let temp = decodeURIComponent((new RegExp('[?|&]' + 'code' + '=' + '([^&;]+?)(&|#|;|$)').exec(link) ||
// [, ''])[1].replace(/\+/g, '%20')) || null
// let lifeData = uni.getStorageSync('lifeData')
// if (!lifeData.vuex_token || !lifeData.vuex_userId) {
// this.$u.api.login({
// code: temp
// }).then(res => {
// uni.setStorageSync('lifeData', {
// vuex_token: res.token,
// vuex_userId: res.user_id
// })
// this.$u.vuex('vuex_token', res.token)
// this.$u.vuex('vuex_userId', res.user_id)
// })
// }
// } else {
// this.$u.api.getAppId().then(res => {
// let redirect = encodeURIComponent(link.replace(/#\//, ""))
// window.location.href =
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${res.appid}&redirect_uri=${redirect}&response_type=code&scope=snsapi_base#wechat_redirect`
// })
// }
},
onShow: function() {
console.log('App Show')

@ -2,16 +2,16 @@ const mode = 'devOnline'; //devLocal本地测试、devOnline线上测试
let ROOTPATH = ''; //域名
switch (mode) {
case 'devLocal':
ROOTPATH = "http://192.168.2.5:61111"
ROOTPATH = "http://h5.ali251.langye.net"
break;
case 'devOnline':
ROOTPATH = "https://xxxxx.cn"
ROOTPATH = "http://h5.ali251.langye.net"
break;
case 'production':
ROOTPATH = "https://xxxxx.cn"
ROOTPATH = "http://h5.ali251.langye.net"
break;
default:
throw new Error('未配置环境');
console.log(`未配置环境`);
}
export { ROOTPATH }
export { ROOTPATH }

@ -1,23 +1,29 @@
//api集合
let apiApp = {
login: '/api/login',
getInfo: '/777/777/index',
}
let apiHome = {
hotSearchUrl: '/777/77/hot_search'
login: '/api/mobile/user/wechat-login',
getAppId: '/api/mobile/user/wechat-login-url',
getQuestions: '/api/mobile/quiz/get-questions',
baseFormIndex: '/api/mobile/base-form/index',
baseFormShow: '/api/mobile/base-form/show',
baseFormSave: '/api/mobile/base-form/save',
baseFormDestroy: '/api/mobile/base-form/destroy'
}
// 此处第二个参数vm就是我们在页面使用的this你可以通过vm获取vuex等操作
const install = (Vue, vm) => {
//api方法
let getSearch = (params = {}) => vm.$u.get(apiHome.hotSearchUrl, params);
let getInfo = (params={}) => vm.$u.post(apiApp.getInfo, params);
let login = (params = {}) => vm.$u.get(apiApp.login, params);
let getAppId = (params = {}) => vm.$u.get(apiApp.getAppId, params);
let getQuestions = (params = {}) => vm.$u.get(apiApp.getQuestions, params);
let baseFormIndex = (params = {}) => vm.$u.get(apiApp.baseFormIndex, params);
let baseFormShow = (params = {}) => vm.$u.get(apiApp.baseFormShow, params);
let baseFormSave = (data = {}) => vm.$u.post(apiApp.baseFormSave, data);
let baseFormDestroy = (params = {}) => vm.$u.post(apiApp.baseFormDestroy, params);
// 将各个定义的接口名称统一放进对象挂载到vm.$u.api(因为vm就是this也即this.$u.api)下
vm.$u.api = {getSearch, getInfo};
vm.$u.api = { login, getAppId, getQuestions, baseFormIndex, baseFormShow, baseFormSave, baseFormDestroy };
}
export default {
install
}
}

@ -11,7 +11,7 @@ const install = (Vue, vm) => {
loadingMask: true, // 展示loading的时候是否给一个透明的蒙层防止触摸穿透
loadingText: '加载中', // 请求loading中的文字提示
loadingTime: 800,
originalData: false, // 是否在拦截器中返回服务端的原始数据
originalData: true, // 是否在拦截器中返回服务端的原始数据
// 设置自定义头部content-type
header: {
'content-type': 'application/json;charset=UTF-8'
@ -21,49 +21,45 @@ const install = (Vue, vm) => {
// 请求拦截部分,如配置,每次请求前都会执行
Vue.prototype.$u.http.interceptor.request = (config) => {
console.log('config-http', config)
// 引用token
// 方式一存放在vuex的token假设使用了uView封装的vuex方式
// 见https://uviewui.com/components/globalVariable.html
config.header.token = vm.vuex_token;
config.data.activity_tag = 'map_point'
config.data.activity_list_id = 7
// 方式二如果没有使用uView封装的vuex方法那么需要使用$store.state获取
// config.header.token = vm.$store.state.token;
// 方式三如果token放在了globalData通过getApp().globalData获取
// config.header.token = getApp().globalData.username;
// 方式四如果token放在了Storage本地存储中拦截是每次请求都执行的
// 所以哪怕您重新登录修改了Storage下一次的请求将会是最新值
// const token = uni.getStorageSync('token');
// config.header.token = token;
let lifeData = uni.getStorageSync('lifeData')
let vuex_token = lifeData.vuex_token;
if (vuex_token || vm.vuex_token) {
config.header['Authorization'] = `Bearer ${vuex_token || vm.vuex_token}`;
}
// 可以对某个url进行特别处理此url参数为this.$u.get(url)中的url值
if (config.url == '/test/jam') config.header.noToken = true;
// 最后需要将config进行return
return config;
// 如果return一个false值则会取消本次请求
// if(config.url == '/user/rest') return false; // 取消某次请求
}
// 响应拦截,如配置,每次请求结束都会执行本方法
Vue.prototype.$u.http.interceptor.response = (res) => {
console.log('res-http',res)
if (res.code == 200) {
// res为服务端返回值可能有coderesult等字段
// 这里对res.result进行返回将会在this.$u.post(url).then(res => {})的then回调中的res的到
// 如果配置了originalData为true请留意这里的返回值
return res.result;
} else if (res.code == 201) {
// 假设201为token失效这里跳转登录
// vm.$u.toast('验证失败,请重新登录');
// setTimeout(() => {
// // 此为uView的方法详见路由相关文档
// vm.$u.route('/pages/user/login')
// }, 1500)
return false;
console.log('res-http', res)
if (res.statusCode === 200) {
if (res.data.hasOwnProperty("errcode")) {
uni.showToast({
icon: "none",
title: res?.data?.errmsg
})
if (res.data?.errcode === 40001) {
setTimeout(() => {
let origin = window.location.origin;
let pathname = window.location.pathname;
window.location.href = origin + pathname;
}, 1500)
}
return false;
} else {
return res.data;
}
} else {
// 如果返回false则会调用Promise的reject回调
// 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中res为服务端的返回值
uni.showToast({
icon: "none",
title: res.statusCode
})
return false;
}
}

@ -26,6 +26,12 @@
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/certificate/certificate",
"style": {
"navigationStyle": "custom"
}
}
],
"subPackages": [],

@ -0,0 +1,32 @@
<template>
<div class="body">
<u-image class="bkg" :src="require('@/static/certificate-bkg.png')" mode="widthFix"></u-image>
<div class>
</div>
</div>
</template>
<script>
export default {
data() {
return {};
}
}
</script>
<style lang="scss">
.body {
position: relative;
}
.bkg {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
</style>

@ -1,6 +1,6 @@
<template>
<view @click="$u.throttle(toAnswer)">
<iframe src="static/html/explanation.html" frameborder="0"></iframe>
<iframe ref="iframe" src="static/html/explanation.html" frameborder="0"></iframe>
</view>
</template>
@ -14,11 +14,42 @@ export default {
uni.navigateTo({
url: '/pages/answer/answer'
})
},
async getDetail (id) {
const res = await this.$u.api.baseFormShow({
table_name: 'map_points',
'with_relations[0]': 'image',
'with_relations[1]': 'video',
id
})
return res
},
async getVrs (id) {
const res = await this.$u.api.baseFormIndex({
table_name: 'map_point_contents',
'with_relations[0]': 'image',
'with_relations[1]': 'video',
'filter[0][key]': 'map_point_id',
'filter[0][op]': 'eq',
'filter[0][value]': id
})
return res
}
},
onLoad() {
onLoad(option) {
window.toAnswer = this.toAnswer
}
this.$nextTick(() => {
this.$refs['iframe'].onload = async () => {
let detail = await this.getDetail(option.id)
let vrs = await this.getVrs(option.id)
this.$refs['iframe'].contentWindow.setDomData({ detail , vrs })
}
})
},
}
</script>

@ -13,9 +13,9 @@
v-for="(item, index) in pointers"
:key="index"
:style="{ 'transform': `translate(calc(${area.w * item.x / 100}px - 50%),calc(${area.h * item.y / 100}px - 50%))` }"
@click="$u.throttle(toDetail)">
@click="$u.throttle(() => toDetail(index))">
<div class="box" :style="{ 'transform': `rotate(${item.d}deg)` }">
<img :style="{ 'transform': `rotate(${-item.d}deg)` }" src="https://img0.baidu.com/it/u=4189294971,2509024565&fm=253&fmt=auto&app=138&f=JPEG?w=667&h=500" alt="">
<img :style="{ 'transform': `rotate(${-item.d}deg)` }" :src="item.image.url" alt="">
</div>
@ -23,7 +23,7 @@
:style="{
'transform': translateText(item.d)
}">
苏州革命博物馆
{{ item.name }}
</div>
</div>
</div>
@ -100,15 +100,41 @@ export default {
};
},
methods: {
toDetail () {
toDetail (id) {
uni.navigateTo({
url: '/pages/detail/detail'
url: `/pages/detail/detail?id=${id}`
})
},
load () {
this.area.w = this.$refs['image'].getBoundingClientRect().width
this.area.h = this.$refs['image'].getBoundingClientRect().height
},
async getPoints () {
function convertToEquivalentAngle(angle) {
if (angle > 180) {
return angle - 360;
} else if (angle < -180) {
return angle + 360;
} else {
return angle;
}
}
this.pointers = []
const res = await this.$u.api.baseFormIndex({
table_name: 'map_points',
with_relations: ['image']
})
this.pointers = res.data.map((i, index) => {
return {
name: i.name,
x: typeof i.x === 'string' ? Number(i.x) : 0,
y: typeof i.y === 'string' ? Number(i.y) : 0,
d: convertToEquivalentAngle(30 * index + 1),
image: i.image
}
})
}
},
@ -130,6 +156,9 @@ export default {
},
mounted() {
},
onShow() {
this.getPoints()
}
}
</script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

@ -241,7 +241,7 @@
timer = setInterval(function() {
index = ($(".swiper-btn li.on").index() + 1) % length;
console.log(index);
$('..swiper-btn li').eq(index).stop().addClass('on');
$('.swiper-btn li').eq(index).stop().addClass('on');
$('.swiper-btn li').eq(index).siblings('li').stop().removeClass('on');
$('.swiper-list[data-num=' + index + ']').stop().fadeIn().siblings(".swiper-list").stop().hide();
if(index == 0){
@ -304,6 +304,10 @@
});
function setDomData (obj) {
let { detail, vrs } = obj;
console.log($('.newstext').children('p')[1].innerHTML = obj.a)
}
</script>
</body>
</html>

@ -142,7 +142,7 @@ textarea::-webkit-input-placeholder{ color:#aaa; }
-moz-box-sizing: border-box;
}
.common-title img{
}
.vrbox{
margin-top: -1rem;
@ -243,7 +243,7 @@ textarea::-webkit-input-placeholder{ color:#aaa; }
background-image: url(../images/bg1.png);
background-repeat: no-repeat;
background-position: left center;
}
.study-party{
float: left;
@ -319,7 +319,7 @@ textarea::-webkit-input-placeholder{ color:#aaa; }
width: 30.511%;
}
.studyContent{
.studyContent{
padding: 1.8rem 1.6rem;
}
.tit-top{
@ -359,8 +359,8 @@ textarea::-webkit-input-placeholder{ color:#aaa; }
background: -moz-linear-gradient(rgba(255,255,255,.8), rgba(255,255,255,1));
background: -o-linear-gradient(rgba(255,255,255,.8), rgba(255,255,255,1));
background: -webkit-linear-gradient(rgba(255,255,255,.8), rgba(255,255,255,1));
}
}
.lookMore::after{
content: " ";
display: inline-block;

@ -33,7 +33,7 @@ const store = new Vuex.Store({
// 如果上面从本地获取的lifeData对象下有对应的属性就赋值给state中对应的变量
// 加上vuex_前缀是防止变量名冲突也让人一目了然
vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {},
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '1945|mGcboS5ApGYxvWUUJNk2ytorapfOU18d20AgiXqJ',
// 如果vuex_version无需保存到本地永久存储无需lifeData.vuex_version方式
vuex_version: '1.0.0',
},

Loading…
Cancel
Save