118 lines
2.9 KiB
Vue
118 lines
2.9 KiB
Vue
<template>
|
||
<view class="container">
|
||
<view class="intro">本项目已包含uni ui组件,无需import和注册,可直接使用。在代码区键入字母u,即可通过代码助手列出所有可用组件。光标置于组件名称处按F1,即可查看组件文档。</view>
|
||
<text class="intro">详见:</text>
|
||
<uni-link :href="href" :text="href"></uni-link>
|
||
<uni-fav></uni-fav>
|
||
<lime-painter :board="base"></lime-painter>
|
||
<button @click="enter()">跳转</button>
|
||
<button @getuserinfo='getUserInfo' open-type="getUserInfo" type="primary" class='login'>微信授权登录</button>
|
||
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import lime from "../../components/lime-painter"
|
||
|
||
export default {
|
||
data () {
|
||
return {
|
||
href: 'https://uniapp.dcloud.io/component/README?id=uniui',
|
||
base: {
|
||
width: '686rpx',
|
||
height: '130rpx',
|
||
views: [
|
||
{
|
||
type: 'view',
|
||
css: {
|
||
left: '0rpx',
|
||
top: '0rpx',
|
||
background: '#07c160',
|
||
width: '120rpx',
|
||
height: '120rpx'
|
||
}
|
||
}
|
||
]
|
||
}
|
||
}
|
||
},
|
||
|
||
created () {
|
||
// this.GetIndex()
|
||
},
|
||
components: {
|
||
lime
|
||
},
|
||
methods: {
|
||
enter() {
|
||
// #ifdef MP-WEIXIN
|
||
uni.getProvider({
|
||
service: 'oauth',
|
||
success: function (res) {
|
||
if (~res.provider.indexOf('weixin')) {
|
||
uni.login({
|
||
provider: 'weixin',
|
||
success: (res2) => {
|
||
console.log(res2)
|
||
uni.getUserInfo({
|
||
provider: 'weixin',
|
||
success: (info) => {//这里请求接口
|
||
console.log(res2);
|
||
console.log(info);
|
||
},
|
||
fail: () => {
|
||
uni.showToast({title:"微信登录授权失败1",icon:"none"});
|
||
}
|
||
})
|
||
|
||
},
|
||
fail: () => {
|
||
uni.showToast({title:"微信登录授权失败2",icon:"none"});
|
||
}
|
||
})
|
||
|
||
}else{
|
||
uni.showToast({
|
||
title: '请先安装微信或升级版本',
|
||
icon:"none"
|
||
});
|
||
}
|
||
}
|
||
});
|
||
//#endif
|
||
},
|
||
getUserInfo(e) {
|
||
|
||
let _this = this;
|
||
|
||
let ret=e.detail;
|
||
|
||
if(ret.errMsg == "getUserInfo:fail auth deny") {
|
||
|
||
_this.$api.toast("为了更好的服务,请同意授权"); //自己封装第一个提示方法
|
||
|
||
}else if(ret.errMsg == "getUserInfo:ok") {
|
||
|
||
console.log(e)
|
||
|
||
}else {
|
||
|
||
_this.$api.toast("授权失败")
|
||
|
||
}
|
||
|
||
},
|
||
async GetIndex () {
|
||
console.log("GetIndex")
|
||
let res = await this.$http.IndexService.Index({});
|
||
console.log("哈哈哈:", res)
|
||
}
|
||
}
|
||
|
||
}
|
||
</script>
|
||
|
||
<style scoped lang="less">
|
||
@import "../../common/less/pages/index.less";
|
||
</style>
|