123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- const { envList } = require('../../envList');
- // pages/me/index.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- openId: '',
- showTip: false,
- title:"",
- content:""
- },
- getOpenId() {
- wx.showLoading({
- title: '',
- });
- wx.cloud
- .callFunction({
- name: 'quickstartFunctions',
- data: {
- type: 'getOpenId',
- },
- })
- .then((resp) => {
- this.setData({
- haveGetOpenId: true,
- openId: resp.result.openid,
- });
- wx.hideLoading();
- })
- .catch((e) => {
- wx.hideLoading();
- const { errCode, errMsg } = e
- if (errMsg.includes('Environment not found')) {
- this.setData({
- showTip: true,
- title: "云开发环境未找到",
- content: "如果已经开通云开发,请检查环境ID与 `miniprogram/app.js` 中的 `env` 参数是否一致。"
- });
- return
- }
- if (errMsg.includes('FunctionName parameter could not be found')) {
- this.setData({
- showTip: true,
- title: "请上传云函数",
- content: "在'cloudfunctions/quickstartFunctions'目录右键,选择【上传并部署-云端安装依赖】,等待云函数上传完成后重试。"
- });
- return
- }
- });
- },
- gotoWxCodePage() {
- wx.navigateTo({
- url: `/pages/exampleDetail/index?envId=${envList?.[0]?.envId}&type=getMiniProgramCode`,
- });
- },
- });
|