12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //app.js
- var http = require('http/request.js');
- var detail = require('http/detail.js');
- App({
- data: {
- hasLogin:false,
- userId:'',
- channel:"blackWhite",
- code:'',
- shareMsg: "找我,帮你省钱😝",
- failed: false,
- winHeight:''
- },
- onLaunch: function () {
- // 展示本地存储能力
- this.windowInfo();
- },
- //页面现实加载,获取群信息
- onShow: function (options) {
- },
- //获取系统消息
- windowInfo: function () {
- var that = this;
- wx.getSystemInfo({
- success: function (res) {
- that.data.winHeight=res.windowHeight
- }
- });
- },
- // 登录
- login(cb) {
- var that = this;
- wx.login({
- success: res => {
- // 发送 res.code 到后台换取 openId, sessionKey, unionId
- if (res.code) {
- //发起网络请求
- cb?cb(res.code):'';
- } else {
- console.log("获取用户登录态失败!" + res.errMsg)
- that.login();
- }
- }
- })
- },
- globalData: {
- userInfo: null
- },
- func: {
- req: http.req
- },
- detailFunc: {
- detail: detail.detail
- },
- //跳转详情页
- goToDetail: function (e,zuId) {
- var goods_id = e.currentTarget.dataset.goods_id;
- var name = e.currentTarget.dataset.name;
- var category_id = zuId;
- wx.navigateTo({
- url: '/pages/detail/detail?goods_id=' + goods_id + '&goods_name=' + name + "&category_id=" + category_id,
- })
- }
- })
|