10.18前的开发
This commit is contained in:
57
unpackage/dist/dev/mp-weixin/pages/user/index.js
vendored
57
unpackage/dist/dev/mp-weixin/pages/user/index.js
vendored
@@ -1,48 +1,41 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const store_index = require("../../store/index.js");
|
||||
const api_index = require("../../api/index.js");
|
||||
const utils_index = require("../../utils/index.js");
|
||||
require("../../api/index.js");
|
||||
require("../../api/request.js");
|
||||
require("../../config/index.js");
|
||||
const _sfc_main = {
|
||||
__name: "index",
|
||||
setup(__props) {
|
||||
store_index.useStore();
|
||||
function getPhoneNumber(e) {
|
||||
console.log(e);
|
||||
getAccess_token({ code: e.detail.code });
|
||||
}
|
||||
async function getAccess_token(params = {}) {
|
||||
const data = {
|
||||
username: params.code,
|
||||
//手机号按钮获取的code
|
||||
type: "wechat_mini_app",
|
||||
identity: "user",
|
||||
password: "111"
|
||||
};
|
||||
await api_index.API.getToken(data);
|
||||
wx_login();
|
||||
}
|
||||
async function wx_login(token_res) {
|
||||
let res = await new Promise((resolve) => {
|
||||
common_vendor.index.login({
|
||||
provider: "weixin",
|
||||
//使用微信登录
|
||||
success: function(loginRes) {
|
||||
resolve(loginRes);
|
||||
console.log(loginRes, "微信登录返回信息");
|
||||
}
|
||||
});
|
||||
common_vendor.onShow(() => {
|
||||
is_login.value = utils_index.custom.checkLogin();
|
||||
if (is_login.value) {
|
||||
userinfo.value = common_vendor.index.getStorageSync("userInfo");
|
||||
avatar.value = common_vendor.index.getStorageSync("avatarUrl");
|
||||
userinfo.value = JSON.parse(userinfo.value);
|
||||
}
|
||||
});
|
||||
const avatar = common_vendor.ref("");
|
||||
common_vendor.ref(null);
|
||||
const is_login = common_vendor.ref(null);
|
||||
const userinfo = common_vendor.ref(null);
|
||||
function toLogin() {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/login/login"
|
||||
});
|
||||
let userId = "";
|
||||
await api_index.API.wx_login({ code: res.code }, userId);
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return {
|
||||
a: common_vendor.o(getPhoneNumber)
|
||||
};
|
||||
return common_vendor.e({
|
||||
a: is_login.value ? avatar.value : "../../static/avatar.png",
|
||||
b: common_vendor.t(is_login.value ? userinfo.value.nickname : "未登录"),
|
||||
c: !is_login.value
|
||||
}, !is_login.value ? {
|
||||
d: common_vendor.o(toLogin)
|
||||
} : {});
|
||||
};
|
||||
}
|
||||
};
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__file", "F:/项目2023/视力表/vision-record/pages/user/index.vue"]]);
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-79e6a490"], ["__file", "F:/项目2023/视力表/vision-record/pages/user/index.vue"]]);
|
||||
wx.createPage(MiniProgramPage);
|
||||
|
@@ -1 +1 @@
|
||||
<view class="user-box page-box"><button class="submit-btn" open-type="getPhoneNumber" bindgetphonenumber="{{a}}"><text>登录</text></button></view>
|
||||
<view class="user-box page-box data-v-79e6a490"><view class="userinfo-box data-v-79e6a490"><image class="data-v-79e6a490" src="{{a}}" mode=""></image><view class=" data-v-79e6a490">{{b}}</view></view><view wx:if="{{c}}" class="btn-box data-v-79e6a490" bindtap="{{d}}"><view class="btn data-v-79e6a490">登录</view></view></view>
|
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.btn-box.data-v-79e6a490 {
|
||||
text-align: center;
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
.btn-box .btn.data-v-79e6a490 {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background: #e2e2e2;
|
||||
color: #26758d;
|
||||
border-radius: 10px;
|
||||
width: 50%;
|
||||
}
|
||||
.userinfo-box.data-v-79e6a490 {
|
||||
color: white;
|
||||
background-color: #26758d;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 40rpx 20rpx;
|
||||
}
|
||||
.userinfo-box image.data-v-79e6a490 {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
border-radius: 50%;
|
||||
background: white;
|
||||
margin-right: 20rpx;
|
||||
}
|
Reference in New Issue
Block a user