提交 2cb1aa0e 编写于 作者: fxy060608's avatar fxy060608

feat(v3): mp runtime

上级 dbb1884c
...@@ -6552,10 +6552,15 @@ var serviceContext = (function () { ...@@ -6552,10 +6552,15 @@ var serviceContext = (function () {
code: err.code, code: err.code,
errMsg: 'login:fail:' + err.message errMsg: 'login:fail:' + err.message
}); });
}); }, { scope: 'email' });
} }
// 先注销再登录 // 先注销再登录
loginServices[provider].logout(login, login); // apple登录logout之后无法重新触发获取email,fullname
if (provider === 'apple') {
login();
} else {
loginServices[provider].logout(login, login);
}
}; };
/** /**
* 微信登录 * 微信登录
...@@ -6594,7 +6599,7 @@ var serviceContext = (function () { ...@@ -6594,7 +6599,7 @@ var serviceContext = (function () {
errMsg: 'operateWXData:fail:请先调用 uni.login' errMsg: 'operateWXData:fail:请先调用 uni.login'
}) })
} }
loginService.getUserInfo(res => { loginService.getUserInfo(res => {
let userInfo; let userInfo;
if (provider === 'weixin') { if (provider === 'weixin') {
const wechatUserInfo = loginService.userInfo; const wechatUserInfo = loginService.userInfo;
...@@ -6608,28 +6613,38 @@ var serviceContext = (function () { ...@@ -6608,28 +6613,38 @@ var serviceContext = (function () {
avatarUrl: wechatUserInfo.headimgurl, avatarUrl: wechatUserInfo.headimgurl,
unionId: wechatUserInfo.unionid unionId: wechatUserInfo.unionid
}; };
} else if (provider === 'apple') {
const appleInfo = loginService.appleInfo;
userInfo = {
openId: appleInfo.user,
fullName: appleInfo.fullName,
email: appleInfo.email,
authorizationCode: appleInfo.authorizationCode,
identityToken: appleInfo.identityToken,
realUserStatus: appleInfo.realUserStatus
};
} else { } else {
loginService.userInfo.openId = loginService.userInfo.openId || loginService.userInfo.openid || loginService.userInfo.openId = loginService.userInfo.openId || loginService.userInfo.openid ||
loginService.authResult.openid; loginService.authResult.openid;
loginService.userInfo.nickName = loginService.userInfo.nickName || loginService.userInfo.nickname; loginService.userInfo.nickName = loginService.userInfo.nickName || loginService.userInfo.nickname;
loginService.userInfo.avatarUrl = loginService.userInfo.avatarUrl || loginService.userInfo.avatarUrl || loginService.userInfo.avatarUrl = loginService.userInfo.avatarUrl || loginService.userInfo.avatarUrl ||
loginService.userInfo.headimgurl; loginService.userInfo.headimgurl;
userInfo = loginService.userInfo; userInfo = loginService.userInfo;
} }
const result = { const result = {
errMsg: 'operateWXData:ok' errMsg: 'operateWXData:ok'
}; };
if (params.data && params.data.api_name === 'webapi_getuserinfo') { if (params.data && params.data.api_name === 'webapi_getuserinfo') {
result.data = { result.data = {
data: JSON.stringify(userInfo), data: JSON.stringify(userInfo),
rawData: '', rawData: '',
signature: '', signature: '',
encryptedData: '', encryptedData: '',
iv: '' iv: ''
}; };
} else { } else {
result.userInfo = userInfo; result.userInfo = userInfo;
} }
invoke$1(callbackId, result); invoke$1(callbackId, result);
}, err => { }, err => {
invoke$1(callbackId, { invoke$1(callbackId, {
...@@ -12245,6 +12260,10 @@ var serviceContext = (function () { ...@@ -12245,6 +12260,10 @@ var serviceContext = (function () {
this.batchData.push([type, typeData]); this.batchData.push([type, typeData]);
} }
find (type, cid) {
return this.batchData.find(data => data[0] === type && data[1][0] === cid)
}
sendPageCreate (data) { sendPageCreate (data) {
this.pageCreateData = data; this.pageCreateData = data;
UniServiceJSBridge.publishHandler(VD_SYNC, { UniServiceJSBridge.publishHandler(VD_SYNC, {
...@@ -12467,8 +12486,18 @@ var serviceContext = (function () { ...@@ -12467,8 +12486,18 @@ var serviceContext = (function () {
if (!this._$vd) { if (!this._$vd) {
return return
} }
this._$vdUpdatedData = Object.create(null); // 当已存在 _$vdMountedData 时,使用重置后的 _$vdMountedData
this._$setData(UPDATED_DATA, this._$vdUpdatedData); const mountedData = this._$vd.find(MOUNTED_DATA, this._$id);
if (mountedData) {
this._$data = Object.create(null); // 清空已有数据
this._$vdUpdatedData = mountedData[1][1] = Object.create(null);
if (process.env.NODE_ENV !== 'production') {
console.log('updated=>mounted:' + this._$id);
}
} else {
this._$vdUpdatedData = Object.create(null);
this._$setData(UPDATED_DATA, this._$vdUpdatedData);
}
this._$newData = Object.create(null); this._$newData = Object.create(null);
}, },
beforeDestroy () { beforeDestroy () {
......
...@@ -227,7 +227,7 @@ const BEHAVIORS = { ...@@ -227,7 +227,7 @@ const BEHAVIORS = {
} }
if (!props.value) { if (!props.value) {
props.value = { props.value = {
type: null type: String // 默认类型为 String,否则默认值为 null,导致一些自定义 input 显示不正确
}; };
} }
} }
......
...@@ -61,7 +61,7 @@ const BEHAVIORS = { ...@@ -61,7 +61,7 @@ const BEHAVIORS = {
} }
if (!props.value) { if (!props.value) {
props.value = { props.value = {
type: null type: String // 默认类型为 String,否则默认值为 null,导致一些自定义 input 显示不正确
} }
} }
} }
......
...@@ -22,7 +22,7 @@ export function unsubscribe (event, callback) { ...@@ -22,7 +22,7 @@ export function unsubscribe (event, callback) {
export function subscribeHandler (event, args, pageId) { export function subscribeHandler (event, args, pageId) {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
console.log(`[subscribeHandler][${Date.now()}]:`, event, args, pageId) console.log(`[subscribeHandler][${Date.now()}]:${event}, ${JSON.stringify(args)}, ${pageId}`)
} }
return emit('view.' + event, args, pageId) return emit('view.' + event, args, pageId)
} }
......
...@@ -19,7 +19,7 @@ export function unsubscribe (event, callback) { ...@@ -19,7 +19,7 @@ export function unsubscribe (event, callback) {
export function subscribeHandler (event, args, pageId) { export function subscribeHandler (event, args, pageId) {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
console.log(`[subscribeHandler][${Date.now()}]:`, event, args, pageId) console.log(`[subscribeHandler][${Date.now()}]:${event}, ${JSON.stringify(args)}, ${pageId}`)
} }
emit('service.' + event, args, pageId) emit('service.' + event, args, pageId)
} }
......
...@@ -99,8 +99,18 @@ export function initData (Vue) { ...@@ -99,8 +99,18 @@ export function initData (Vue) {
if (!this._$vd) { if (!this._$vd) {
return return
} }
this._$vdUpdatedData = Object.create(null) // 当已存在 _$vdMountedData 时,使用重置后的 _$vdMountedData
this._$setData(UPDATED_DATA, this._$vdUpdatedData) const mountedData = this._$vd.find(MOUNTED_DATA, this._$id)
if (mountedData) {
this._$data = Object.create(null) // 清空已有数据
this._$vdUpdatedData = mountedData[1][1] = Object.create(null)
if (process.env.NODE_ENV !== 'production') {
console.log('updated=>mounted:' + this._$id)
}
} else {
this._$vdUpdatedData = Object.create(null)
this._$setData(UPDATED_DATA, this._$vdUpdatedData)
}
this._$newData = Object.create(null) this._$newData = Object.create(null)
}, },
beforeDestroy () { beforeDestroy () {
......
...@@ -160,6 +160,10 @@ export class VDomSync { ...@@ -160,6 +160,10 @@ export class VDomSync {
this.batchData.push([type, typeData]) this.batchData.push([type, typeData])
} }
find (type, cid) {
return this.batchData.find(data => data[0] === type && data[1][0] === cid)
}
sendPageCreate (data) { sendPageCreate (data) {
this.pageCreateData = data this.pageCreateData = data
UniServiceJSBridge.publishHandler(VD_SYNC, { UniServiceJSBridge.publishHandler(VD_SYNC, {
......
...@@ -96,6 +96,8 @@ function vdSync ({ ...@@ -96,6 +96,8 @@ function vdSync ({
}) })
vd.flush() vd.flush()
Vue.nextTick(() => { Vue.nextTick(() => {
// 清空本次 addBatchData
vd.clearAddBatchVData()
updateView() updateView()
isVdCallback && UniViewJSBridge.publishHandler(VD_SYNC_CALLBACK) isVdCallback && UniViewJSBridge.publishHandler(VD_SYNC_CALLBACK)
}) })
......
...@@ -49,6 +49,10 @@ export class VDomSync { ...@@ -49,6 +49,10 @@ export class VDomSync {
}) })
} }
clearAddBatchVData () {
this.addBatchVData.length = 0
}
flush () { flush () {
this.updateBatchVData.forEach(([cid, data]) => { this.updateBatchVData.forEach(([cid, data]) => {
const vm = this.vms[cid] const vm = this.vms[cid]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册