pazhao
// pages/mine/mine.js
import {
request
} from "../../utils/request";
import wxjs from '../../js_sdk/junyi-h5-copy/junyi-h5-copy/jssdk.js'
export default {
data() {
return {
wxOpenTags: '1213'
};
},
components: {},
props: {},
/**
* --
*/
onLoad: function(options) {
},
/**
* --
*/
onReady: function() {
const that = this;
const params = {
ulr: 'https://miniapp.coretecnology.com/h5/wxstore/pages/test/test'
};
wx.showLoading({
title: ' ',
icon: 'none',
mask: true
});
request.post('/GET/wxSign ', params).then(res => {
console.log(res);
if (res.status == 'S') {
wxjs.config({
debug: true, // , api alert , , pc , log , pc 。
appId: res.data.appId, // ,
timestamp: res.data.timestamp, // ,
nonceStr: res.data.nonceStr, // ,
signature: res.data.signature, // ,
jsApiList: ['onMenuShareTimeline','chooseImage'], // , JS
openTagList: ['wx-open-launch-weapp'] // , , ['wx-open-launch-app']
})
wxjs.ready(function() {
//#ifdef H5
setTimeout(()=>{
that.wxOpenTags=`<wx-open-launch-weapp path="pages/index/index.html" id="launch-wxapp" username="gh_c2425c446cfc">
<template>
<style>
.btn-open-weapp{
background: linear-gradient(to right, #ffd52e 0%, #ffef93 50%, #ffd52e 100%);
border: 0;
color: #424242;
text-shadow: 0px 1px 1px #fff;
border-radius: 50px;
text-align: center;
width: 120px;
height: 35px;
line-height: 35px;
outline:none;
}
</style>
<button class="btn-open-weapp"> </button >
</template>
</wx-open-launch-weapp>`;
},1000);
//#endif
});
wxjs.error(function(res) {
// config error , , config debug , res , SPA
});
} else {
wx.showToast({
title: res.message,
icon: 'none',
duration: 3000
});
}
});
},
/**
* --
*/
onShow: function() {
var that = this;
that.isInApplets()
wx.setNavigationBarTitle({
title: ' '
})
},
/**
* --
*/
onHide: function() {},
/**
* --
*/
onUnload: function() {},
/**
* --
*/
onPullDownRefresh: function() {},
/**
*
*/
onReachBottom: function() {},
/**
*
*/
onShareAppMessage: function() {},
methods: {
pazhao(){
wxjs.chooseImage({
count: 1, // 9
sizeType: ['original', 'compressed'], // ,
sourceType: ['album', 'camera'], // ,
success: function (res) {
var localIds = res.localIds; // ID ,localId img src
}
});
},
handleLaunchFn(e) {
alert(e.detail)
},
handleErrorFn(e) {
console.log('fail', e.detail);
alert(e.detail)
},
isInApplets() {
var that = this
console.log('jinlaile ')
wxjs.miniProgram.getEnv(function(res) { //
console.log('jinlaile ')
if (res.miniprogram) { // true
that.setData({
path: ' '
})
} else { // false
that.setData({
path: ' '
})
}
});
}
}
};