123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <template>
- <view class="main">
- <view class="wx">
- <view class="wx_1">
- <text class="iconfont icon-weixin"></text>
- </view>
- <view class="wx_2">
- <button size="mini" @tap="otherLogin()">微信信任登录</button>
- </view>
- <view class="wx_3">
- <checkbox-group @change="changeAgree">
- <label>
- <checkbox :checked="agree" />
- <text @tap.stop="toAgree()">我已阅读并同意“用户协议”和“隐私政策”</text>
- </label>
- </checkbox-group>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 用户协议
- agree: false,
- // 注册账号信息
- user: {},
- id: '',
- // 类型
- type: '',
- };
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- that.$set(that, `type`, e && e.type || '');
- that.search();
- },
- onShow: function() {
- const that = this;
- // 查询平台信息
- that.searchOpenids();
- },
- methods: {
- // 查询
- async search() {
- const that = this;
- },
- async searchOpenids() {
- const that = this;
- uni.getStorage({
- key: 'openid',
- success: function(res) {
- that.$set(that, `openid`, res.data);
- },
- fail: function(err) {
- uni.login({
- success: async function(res) {
- if (res.code) {
- const aee = await that.$app('/wechat/api/login/app',
- 'GET', {
- js_code: res.code,
- config: that.$config.wx_projectkey
- })
- if (aee.errcode == '0') {
- uni.setStorage({
- key: "openid",
- data: aee.data.openid
- })
- that.$set(that, `openid`, aee.data.openid);
- } else {
- uni.showToast({
- title: aee.errmsg,
- icon: 'none'
- })
- }
- } else {
- uni.showToast({
- title: res.errMsg,
- icon: 'none'
- })
- }
- }
- });
- }
- })
- },
- // 其他登录方式
- async otherLogin() {
- const that = this;
- let agree = that.agree;
- let openid = that.openid;
- if (agree) {
- if (openid) {
- const aee = await that.$api(`/login/wxapp/${openid}`, 'POST', {})
- if (aee.errcode == '0') {
- uni.reLaunch({
- url: `/pages/home/index`
- })
- } else {
- uni.showToast({
- title: aee.errmsg,
- icon: 'none'
- })
- }
- } else {
- uni.showToast({
- title: '系统更新中,请稍后再试!',
- icon: 'none'
- })
- }
- } else {
- uni.showToast({
- title: '请阅读并同意用户协议和隐私政策',
- icon: 'none'
- })
- }
- },
- // 同意隐私协议
- changeAgree() {
- const that = this;
- let agree = !that.agree
- that.$set(that, `agree`, agree);
- },
- // 查看隐私协议
- toAgree() {
- const that = this;
- uni.navigateTo({
- url: `/pagesHome/other/agree`
- })
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 100vh;
- .wx {
- text-align: center;
- margin: 25vw 0 0 0;
- .wx_1 {
- margin: 0 0 5vw 0;
- .iconfont {
- color: var(--f35BColor);
- }
- text {
- font-size: 50px;
- }
- }
- .wx_2 {
- button {
- background: var(--f35BColor);
- color: var(--fffColor);
- font-size: var(--font16Size);
- }
- }
- .wx_3 {
- position: absolute;
- bottom: 10vw;
- text-align: center;
- font-size: 12px;
- }
- }
- }
- </style>
|