場景一
只申請小程序碼
1.登陸微信小程序平臺
想要生成微信的小程序碼,首先要登陸到微信公眾平臺官網(wǎng),直接在頁面上輸入已經(jīng)注冊好的小程序賬號以及密碼,成功登陸之后,直接選擇頁面右上方的【工具】,下拉找到【生成小程序碼】這個選項(xiàng),這是生成微信小程序碼之前的操作。商家需要先注冊微信小程序,才可以有小程序碼使用。
項(xiàng)目里小程序碼
前端
weixin: {
getAccessTokenURL:
"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential",
appid: "", //小程序appid
secret: "", //小程序秘鑰
base64: "",
page: "pages/sign/sign", //跳轉(zhuǎn)頁面
env_version: "release",
},
// 調(diào)取接口
async accessToken() {
let docNo = this.data.mainData.docNo;
let weixin = this.weixin;
let res = await this.api.getAccessToken({
appid: weixin.appid,
secret: weixin.secret,
scene: docNo,
page: weixin.page,
check_path: true,
env_version: weixin.env_version,
});
console.log(res);
this.weixin.base64 = res;
},

image.png
后端方法

image.png