Commit 8d83067d authored by 潘永坪's avatar 潘永坪

登录授权完成

parent 27852e43
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
//但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】 //但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
// 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created // 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
// 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted // 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default { export default {
onLaunch: function() {//初始化完成时触发(全局只触发一次 onLaunch: function() {//初始化完成时触发(全局只触发一次
console.log('App Launch') console.log('App Launch')
......
...@@ -5,12 +5,6 @@ ...@@ -5,12 +5,6 @@
"style": { "style": {
"navigationBarTitleText": "胖丁旅游" "navigationBarTitleText": "胖丁旅游"
} }
},
{
"path": "pages/my/my",
"style": {
"navigationBarTitleText": "个人中心"
}
} }
], ],
......
...@@ -50,9 +50,9 @@ ...@@ -50,9 +50,9 @@
</view> </view>
</view> --> </view> -->
<!-- <button @click="getUserInfo()"> 授权获取头像昵称 </button> -->
<view class="bottom"> <view class="bottom">
<!-- <web-view src="https://wx.pangdly.com"></web-view> --> <web-view src="https://wx.pangdly.com"></web-view>
</view> </view>
</view> </view>
</template> </template>
...@@ -81,66 +81,36 @@ ...@@ -81,66 +81,36 @@
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => { _this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){ if(res.code=='00'){
let openid=res.data.openid let openid=res.data.openid
console.log(openid) uni.setStorageSync('openid',openid)
}else{ }else{
uni.removeStorageSync('openid')
uni.showToast({ uni.showToast({
title:res.message, title:res.message,
icon:"fail" icon:"none"
}) })
} }
}).catch((err)=>{
uni.removeStorageSync('openid')
}) })
} }
// 获取用户信息
// uni.getUserInfo({
// provider: 'weixin',
// success: function (infoRes) {
// console.log('用户昵称为:' + infoRes.userInfo.nickName);
// }
// });
} }
}) })
//#endif //#endif
// wx.login({
// success: (res) => {
// if (res.code) { //微信登录成功 已拿到code
// uni.request({
// url: 'https://www.xx123.com//common/unionId.do', //演示地址,请以你的后端接口为准
// method:'POST',
// data: {
// code: res.code //wx.login 登录成功后的code
// },
// success: (cts) => {
// // 换取成功后 暂存这些数据 留作后续操作
// this.openid=cts.data.openid //openid 用户唯一标识
// this.unionid=cts.data.unionid //unionid 开放平台唯一标识
// this.session_key=cts.data.session_key //session_key 会话密钥
// }
// });
// } else {
// console.log('登录失败!' + res.errMsg)
// }
// }
// })
}, },
methods: { methods: {
aaa(){ getUserInfo() { // 获取用户信息
let data = { uni.getUserProfile({
// "orderId":"z001620960580734af478660cca93511", //订单Id lang:'zh_CN',
// "userId":"oh2UV1lyYABHMZ1rMlgjhVHyyYDQ", //用户Id desc:'登录',
// "payType":31, //支付类型 success:(res)=>{
} console.log(res);
this.$request('orderc/thirdOrder/findOrderInfo',data).then(res => { },
if(res.code=='00'){ fail:(res)=>{
alert('成功') console.log(res)
}else{
uni.showToast({
title:res.message,
icon:"success"
})
} }
}) })
} },
} }
} }
</script> </script>
......
<template>
<view>
个人中心
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style>
</style>
{ {
"pages": [ "pages": [
"pages/index/index", "pages/index/index"
"pages/my/my"
], ],
"subPackages": [], "subPackages": [],
"window": { "window": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/index/index"],{"065f":function(n,t,e){"use strict";e.r(t);var o=e("737f"),c=e.n(o);for(var u in o)"default"!==u&&function(n){e.d(t,n,(function(){return o[n]}))}(u);t["default"]=c.a},"2bba":function(n,t,e){"use strict";(function(n){e("6909");o(e("66fd"));var t=o(e("c545"));function o(n){return n&&n.__esModule?n:{default:n}}n(t.default)}).call(this,e("543d")["createPage"])},5514:function(n,t,e){"use strict";var o;e.d(t,"b",(function(){return c})),e.d(t,"c",(function(){return u})),e.d(t,"a",(function(){return o}));var c=function(){var n=this,t=n.$createElement;n._self._c},u=[]},"737f":function(n,t,e){"use strict";(function(n){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e={data:function(){return{title:"胖丁首页"}},onLoad:function(){},onReady:function(){var t=this;n.login({provider:"weixin",success:function(e){if(e.code){var o={code:e.code,source:3};t.$request("wechat/wx/getUserInfoByCode",o).then((function(t){"00"==t.code||n.showToast({title:t.message,icon:"fail"})}))}}})},methods:{aaa:function(){var t={};this.$request("orderc/thirdOrder/findOrderInfo",t).then((function(t){"00"==t.code?alert("成功"):n.showToast({title:t.message,icon:"success"})}))}}};t.default=e}).call(this,e("543d")["default"])},c545:function(n,t,e){"use strict";e.r(t);var o=e("5514"),c=e("065f");for(var u in c)"default"!==u&&function(n){e.d(t,n,(function(){return c[n]}))}(u);e("d9b5");var r,a=e("f0c5"),i=Object(a["a"])(c["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],r);t["default"]=i.exports},d9b5:function(n,t,e){"use strict";var o=e("e90d"),c=e.n(o);c.a},e90d:function(n,t,e){}},[["2bba","common/runtime","common/vendor"]]]); (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/index/index"],{"065f":function(e,n,t){"use strict";t.r(n);var o=t("737f"),c=t.n(o);for(var u in o)"default"!==u&&function(e){t.d(n,e,(function(){return o[e]}))}(u);n["default"]=c.a},"2bba":function(e,n,t){"use strict";(function(e){t("6909");o(t("66fd"));var n=o(t("c545"));function o(e){return e&&e.__esModule?e:{default:e}}e(n.default)}).call(this,t("543d")["createPage"])},"737f":function(e,n,t){"use strict";(function(e){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var t={data:function(){return{title:"胖丁首页"}},onLoad:function(){},onReady:function(){var n=this;e.login({provider:"weixin",success:function(t){if(t.code){var o={code:t.code,source:3};n.$request("wechat/wx/getUserInfoByCode",o).then((function(n){if("00"==n.code){var t=n.data.openid;e.setStorageSync("openid",t)}else e.removeStorageSync("openid"),e.showToast({title:n.message,icon:"none"})})).catch((function(n){e.removeStorageSync("openid")}))}}})},methods:{getUserInfo:function(){e.getUserProfile({lang:"zh_CN",desc:"登录",success:function(e){console.log(e)},fail:function(e){console.log(e)}})}}};n.default=t}).call(this,t("543d")["default"])},c545:function(e,n,t){"use strict";t.r(n);var o=t("e3d4"),c=t("065f");for(var u in c)"default"!==u&&function(e){t.d(n,e,(function(){return c[e]}))}(u);t("d9b5");var i,r=t("f0c5"),a=Object(r["a"])(c["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],i);n["default"]=a.exports},d9b5:function(e,n,t){"use strict";var o=t("e90d"),c=t.n(o);c.a},e3d4:function(e,n,t){"use strict";var o;t.d(n,"b",(function(){return c})),t.d(n,"c",(function(){return u})),t.d(n,"a",(function(){return o}));var c=function(){var e=this,n=e.$createElement;e._self._c},u=[]},e90d:function(e,n,t){}},[["2bba","common/runtime","common/vendor"]]]);
\ No newline at end of file \ No newline at end of file
<view class="bottom"></view> <view class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file \ No newline at end of file
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/my/my"],{"10ae":function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var u={data:function(){return{}},methods:{}};n.default=u},"2b4e":function(t,n,e){"use strict";var u;e.d(n,"b",(function(){return r})),e.d(n,"c",(function(){return c})),e.d(n,"a",(function(){return u}));var r=function(){var t=this,n=t.$createElement;t._self._c},c=[]},c3d3:function(t,n,e){"use strict";(function(t){e("6909");u(e("66fd"));var n=u(e("d7cf"));function u(t){return t&&t.__esModule?t:{default:t}}t(n.default)}).call(this,e("543d")["createPage"])},d178:function(t,n,e){"use strict";e.r(n);var u=e("10ae"),r=e.n(u);for(var c in u)"default"!==c&&function(t){e.d(n,t,(function(){return u[t]}))}(c);n["default"]=r.a},d7cf:function(t,n,e){"use strict";e.r(n);var u=e("2b4e"),r=e("d178");for(var c in r)"default"!==c&&function(t){e.d(n,t,(function(){return r[t]}))}(c);var a,f=e("f0c5"),o=Object(f["a"])(r["default"],u["b"],u["c"],!1,null,null,null,!1,u["a"],a);n["default"]=o.exports}},[["c3d3","common/runtime","common/vendor"]]]);
\ No newline at end of file
{
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false,
"usingComponents": {}
}
\ No newline at end of file
<view>个人中心</view>
\ No newline at end of file
{ {
"pages": [ "pages": [
"pages/index/index", "pages/index/index"
"pages/my/my"
], ],
"subPackages": [], "subPackages": [],
"window": { "window": {
......
...@@ -96,6 +96,7 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default = ...@@ -96,6 +96,7 @@ Object.defineProperty(exports, "__esModule", { value: true });exports.default =
//但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】 //但是Vue的生命周期依然有效 【Vue的生命周期在任何地方都是有效的,即你仍然可以在uni-app项目中使用Vue生命周期,但是不建议这么做】
// 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created // 2、推荐使用uni-app里面的onLoad 代替 vue 里面的 created
// 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted // 3、推荐使用uni-app里面的onReady 代替 vue 里面的 mounted
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
var _default = { var _default = {
onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次 onLaunch: function onLaunch() {//初始化完成时触发(全局只触发一次
console.log('App Launch'); console.log('App Launch');
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
/* /*
1.页面背景颜色#f7f7f7 1.页面背景颜色#f7f7f7
2.分隔线颜色#DBDBDB 2.分隔线颜色#DBDBDB
......
...@@ -219,65 +219,34 @@ var _default = ...@@ -219,65 +219,34 @@ var _default =
_this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) { _this.$request('wechat/wx/getUserInfoByCode', data).then(function (res) {
if (res.code == '00') { if (res.code == '00') {
var openid = res.data.openid; var openid = res.data.openid;
console.log(openid); uni.setStorageSync('openid', openid);
} else { } else {
uni.removeStorageSync('openid');
uni.showToast({ uni.showToast({
title: res.message, title: res.message,
icon: "fail" }); icon: "none" });
} }
}).catch(function (err) {
uni.removeStorageSync('openid');
}); });
} }
// 获取用户信息
// uni.getUserInfo({
// provider: 'weixin',
// success: function (infoRes) {
// console.log('用户昵称为:' + infoRes.userInfo.nickName);
// }
// });
} }); } });
// wx.login({
// success: (res) => {
// if (res.code) { //微信登录成功 已拿到code
// uni.request({
// url: 'https://www.xx123.com//common/unionId.do', //演示地址,请以你的后端接口为准
// method:'POST',
// data: {
// code: res.code //wx.login 登录成功后的code
// },
// success: (cts) => {
// // 换取成功后 暂存这些数据 留作后续操作
// this.openid=cts.data.openid //openid 用户唯一标识
// this.unionid=cts.data.unionid //unionid 开放平台唯一标识
// this.session_key=cts.data.session_key //session_key 会话密钥
// }
// });
// } else {
// console.log('登录失败!' + res.errMsg)
// }
// }
// })
}, },
methods: { methods: {
aaa: function aaa() { getUserInfo: function getUserInfo() {// 获取用户信息
var data = { uni.getUserProfile({
// "orderId":"z001620960580734af478660cca93511", //订单Id lang: 'zh_CN',
// "userId":"oh2UV1lyYABHMZ1rMlgjhVHyyYDQ", //用户Id desc: '登录',
// "payType":31, //支付类型 success: function success(res) {
}; console.log(res);
this.$request('orderc/thirdOrder/findOrderInfo', data).then(function (res) { },
if (res.code == '00') { fail: function fail(res) {
alert('成功'); console.log(res);
} else { } });
uni.showToast({
title: res.message,
icon: "success" });
}
});
} } };exports.default = _default; } } };exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"])) /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"]))
......
<view class="bottom"></view> <view class="bottom"><web-view src="https://wx.pangdly.com"></web-view></view>
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
{
"navigationBarTitleText": "个人中心",
"usingComponents": {}
}
\ No newline at end of file
<view>个人中心</view>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment