完成搜索页面
This commit is contained in:
+3
-1
@@ -27,6 +27,7 @@ import {
|
||||
Switch,
|
||||
Cascader,
|
||||
ActionSheet,
|
||||
ShareSheet,
|
||||
Dialog
|
||||
} from "vant";
|
||||
|
||||
@@ -35,8 +36,9 @@ Vue.use(NavBar);
|
||||
Vue.use(Search);
|
||||
Vue.use(Swipe);
|
||||
Vue.use(SwipeItem);
|
||||
Vue.use(Grid);
|
||||
Vue.use(GridItem);
|
||||
Vue.use(Grid);
|
||||
Vue.use(ShareSheet);
|
||||
Vue.use(NoticeBar);
|
||||
Vue.use(Tabbar);
|
||||
Vue.use(TabbarItem);
|
||||
|
||||
+66
-29
@@ -1,39 +1,44 @@
|
||||
|
||||
let wechatInstance;
|
||||
|
||||
function signToWechat(config){
|
||||
if(!wx){
|
||||
function signToWechat(config) {
|
||||
if (!wx) {
|
||||
console.warn('请安装微信网页JS-SDK, url: https://res2.wx.qq.com/open/js/jweixin-1.6.0.js');
|
||||
}
|
||||
const defaultConfig = {
|
||||
debug: true,
|
||||
}
|
||||
...config,
|
||||
jsApiList: [
|
||||
'onMenuShareTimeline',
|
||||
'onMenuShareAppMessage',
|
||||
'scanQRCode',
|
||||
'getLocation',
|
||||
'openLocation',
|
||||
'updateAppMessageShareData',
|
||||
'updateTimelineShareData'
|
||||
],
|
||||
};
|
||||
return new Promise((resolve) => {
|
||||
wx.config({
|
||||
...defaultConfig,
|
||||
debug: true,
|
||||
...config,
|
||||
})
|
||||
wx.ready(function(){
|
||||
console.warn('wechat sdk config success')
|
||||
console.log('defaultConfig', defaultConfig);
|
||||
wx.config(defaultConfig);
|
||||
wx.ready(function() {
|
||||
console.warn('wechat sdk config success');
|
||||
wechatInstance = wx;
|
||||
resolve(wx)
|
||||
})
|
||||
})
|
||||
resolve(wx);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function getLocation(){
|
||||
function getLocation() {
|
||||
return new Promise(resolve => {
|
||||
wechatInstance.getLocation({
|
||||
type: 'wgs84',
|
||||
success: res => {
|
||||
resolve(res)
|
||||
resolve(res);
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function requestPayment(paymentConfig){
|
||||
function requestPayment(paymentConfig) {
|
||||
return new Promise(resolve => {
|
||||
wechatInstance.chooseWXPay({
|
||||
timestamp: paymentConfig.timestamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
|
||||
@@ -41,18 +46,50 @@ function requestPayment(paymentConfig){
|
||||
package: paymentConfig.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
|
||||
signType: paymentConfig.signType, // 微信支付V3的传入RSA,微信支付V2的传入格式与V2统一下单的签名格式保持一致
|
||||
paySign: paymentConfig.paySign, // 支付签名
|
||||
success: function (res) {
|
||||
// 支付成功后的回调函数
|
||||
resolve(res)
|
||||
success: function(res) {
|
||||
// 支付成功后的回调函数
|
||||
resolve(res);
|
||||
},
|
||||
fail(res){
|
||||
alert(JSON.stringify(res))
|
||||
fail(res) {
|
||||
alert(JSON.stringify(res));
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function openLocation(config){
|
||||
return wechatInstance.openLocation(config)
|
||||
function openLocation(config) {
|
||||
return wechatInstance.openLocation(config);
|
||||
}
|
||||
export { signToWechat, getLocation, requestPayment, openLocation };
|
||||
|
||||
// 分享给朋友
|
||||
function updateAppMessageShareData(title = '', desc = '', link = '', imgUrl = '') {
|
||||
return new Promise((resolve) => {
|
||||
wechatInstance.updateAppMessageShareData({
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
imgUrl,
|
||||
complete: res => {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 分享到朋友圈
|
||||
function updateTimelineShareData(title = '', desc = '', link = '', imgUrl = '') {
|
||||
return new Promise((resolve) => {
|
||||
wechatInstance.updateTimelineShareData({
|
||||
title,
|
||||
desc,
|
||||
link,
|
||||
imgUrl,
|
||||
complete: res => {
|
||||
resolve(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
export { signToWechat, getLocation, requestPayment, openLocation, updateAppMessageShareData, updateTimelineShareData };
|
||||
Reference in New Issue
Block a user