4d9925d8 by joe

基本功能

1 parent c581f236
......@@ -16,6 +16,11 @@
<strong>We're sorry but vue-cli3-framework doesn't work properly without JavaScript enabled. Please enable it to
continue.</strong>
</noscript>
<script src="./js/global-params.js"></script>
<script src="./js/jweixin-1.1.0.js"></script>
<script src="./js/hdp-4.4.0.min.js"></script>
<script src="./js/as.js"></script>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
......
var as = {};
/*------------------初始化基础数据 start---------------------*/
as.domains = "https://k.wxpai.cn/F2Mb";
as.AppID = "44beaf75bc0511e98c527cd30aeb749e";
as.AppKey = "8c2ecbf4a75648c8b0cb04940f461c4c";
//默认头像
as.defineAvatar = "http://cdn.aiwanpai.com/s/d.jpg";
as.shareLink = as.domains + "/index.html";
as.shareImgUrl = as.domains + "/share.jpg";
as.success = function () { };
as.appSuccess = function () { };
as.openid = "";
as.wxUserInfo = {};
as.isSubscribe = false; //是否关注
as.rankName = "rank"; //排行榜名称
/*------------------初始化基础数据 end-----------------------*/
/*------------------HDP初始化 start---------------------*/
HDP.init(as.AppID, as.AppKey);
weixinGetConfig();
hideOptionMenu();
//隐藏分享到朋友圈
// hideMenuItemsTimeLink();
//隐藏微信右上角菜单
// hideOptionMenu();
// 批量隐藏功能按钮接口
// hideMenuItems(
// [
// "menuItem:share:appMessage",
// "menuItem:share:timeline",
// "menuItem:share:qq",
// "menuItem:share:weiboApp",
// "menuItem:favorite",
// "menuItem:share:facebook",
// "menuItem:share:QZone",
// "menuItem:editTag",
// "menuItem:delete",
// "menuItem:copyUrl",
// "menuItem:originPage",
// "menuItem:readMode",
// "menuItem:openWithQQBrowser",
// "menuItem:openWithSafari",
// "menuItem:share:email",
// "menuItem:share:brand"
// ]
// );
//以下初始化不需要使用可以注释掉
as.weixin = HDP.weixin(); //微信
as.redis = HDP.redis(); //keyvaluestore
as.func = HDP.getFunction(); //自定义函数
as.rand = HDP.rand(); //抽奖
// as.piplus = HDP.getPiplus(); //派加接口
as.co = HDP.getAppCooperation(); //协作
// as.rank = HDP.rank(); //排行榜
// as.jpgCdn = HDP.getJpgCDN(); //图片路径转换
as.wxMultimedia = HDP.wxMultimedia(); //语音
as.file = HDP.getFile(); //上传图片
/*------------------HDP初始化 end-----------------------*/
/*------------------微信相关 start---------------------*/
//分享设置
as.setShare = function (link, title, desc, imgurl) {
as.weixin.initShare({
"link": (link != "") ? link : as.shareLink,
"appMessageTitle": (title != "") ? title : as.shareTitle,
"appMessageDesc": (desc != "") ? desc : as.shareDesc,
"appMessageImgUrl": (imgurl != "") ? imgurl : as.shareImgUrl,
"appMessageShareSucc": as.appSuccess,
"timelineTitle": (desc != "") ? desc : as.shareDesc,
"timelineImgUrl": (imgurl != "") ? imgurl : as.shareImgUrl,
"timelineShareSucc": as.success
});
};
as.setShare("", "了解「亚洲万里通」", "", "https://k.wxpai.cn/saMS/share.jpg?v20190625");
//获取用户微信信息
as.getWxUserInfo = function (callback) {
as.weixin.getUserInfoV2({
"success": function (res) {
if (res && res.nickname) {
if (res.nickname.indexOf('"') > -1) {
res.nickname = res.nickname.replace(/"/g, '“');
}
if (res.nickname.indexOf("'") > -1) {
res.nickname = res.nickname.replace(/'/g, "‘");
}
}
if (res && res.avatar == "") {
res.avatar = as.defineAvatar;
}
as.wxUserInfo = res;
if (as.wxUserInfo && as.wxUserInfo.openid) {
as.openid = as.wxUserInfo.openid;
}
if (typeof callback == "function") {
callback(as.openid)
};
},
"error": function (res) {
if (typeof callback == "function") {
callback("")
};
}
});
};
//判断是否关注了公众号
as.isAttention = function (callback) {
as.weixin.isSubscribe({
"success": function (res) {
as.isSubscribe = (res["subscribe"] == 1) ? true : false;
if (typeof callback == "function")
callback(as.isSubscribe);
},
"error": function (res) {
if (typeof callback == "function")
callback(false);
}
});
};
//领取卡券
as.addCard = function (cardId, openid, callback) {
as.weixin.addCard({
"cardId": cardId,
"code": "",
"openid": openid,
"succ": function (res) {
console.log('领取卡券成功');
if (typeof callback == "function")
callback(true);
},
"error": function (res) {
console.log('领取卡券失败');
if (typeof callback == "function")
callback(false);
}
});
};
/*------------------微信相关 end---------------------*/
/*------------------keyvaluestore start---------------------*/
as.setRedisKeyValue = function (key, value, callback) {
var redisOp = {
"param": {
"valueKey": key,
"value": value
},
"success": function (res) {
var bool = res.code == "180001";
if (typeof callback == "function") callback(bool);
},
"error": function (res) {
if (typeof callback == "function") callback(false);
}
};
as.redis.set(redisOp);
};
as.getRedisKeyValue = function (key, callback) {
var redisOp = {
"param": {
"valueKey": key
},
"success": function (res) {
if (res.code == "181001") {
if (typeof callback == "function") callback(res["returnMap"][key]);
} else {
if (typeof callback == "function") callback(null);
}
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
};
as.redis.get(redisOp);
};
as.getRedisList = function (key, callback) {
var redisOp = {
"param": {
"valueKey": key
},
"success": function (res) {
if (res.code == "181001") {
if (typeof callback == "function") callback(res["returnMap"]);
} else {
if (typeof callback == "function") callback(null);
}
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
};
as.redis.getList(redisOp);
};
/*------------------keyvaluestore end-----------------------*/
/*------------------自定义函数 start---------------------*/
//单语句查询
as.queryFun = function (funName, data, callback) {
as.func.runFunction(funName, {
"param": data,
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
//插入,修改,多语句查询
as.queryFunV2 = function (funName, data, callback) {
as.func.runFunctionV2(funName, {
"param": data,
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
/*------------------自定义函数 end---------------------*/
/*------------------抽奖相关 start---------------------*/
//抽奖
as.gameLottery = function (callback) {
as.rand.rand({
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback({
"result": false
});
}
});
};
//时间戳格式化(YYYY-mm-dd)
as.timestampFormat = function (timestamp) {
var myDate = new Date();
if (timestamp) myDate.setTime(timestamp);
var year = myDate.getFullYear();
var month = myDate.getMonth() + 1;
if (month < 10) month = "0" + month;
var day = myDate.getDate();
if (day < 10) day = "0" + day;
var format = "";
format += year + "-" + month + "-" + day;
return format;
};
/*------------------抽奖相关 end-----------------------*/
/*------------------协作相关 start---------------------*/
//从当前链接中获取邀请码 hdp_cooperation_id
as.getCodeFromCurrentUrl = function (callback) {
as.co.getCodeFromCurrentUrl(function (cooperationId) {
if (typeof callback == "function") callback(cooperationId);
});
};
//根据邀请码重置分享链接
as.cooperationSetShareLink = function (resourceId, desc) {
if (resourceId != "") {
if (as.shareLink.indexOf("?") > 0) {
var link = as.shareLink + "&hdp_cooperation_id=" + resourceId;
} else {
var link = as.shareLink + "?hdp_cooperation_id=" + resourceId;
}
as.setShare(link, "", desc, "");
}
};
//生成邀请码
as.insertResourceId = function (jsonStr, callback) {
if (typeof (jsonStr) != 'string') {
jsonStr = JSON.stringify(jsonStr);
}
as.co.uploadAppCooperationInfo({
"param": {
"jsonStr": jsonStr
},
"success": function (res) {
if (res && res.success) {
if (typeof callback == "function") callback(res.content);
} else {
if (typeof callback == "function") callback("");
}
},
"error": function (res) {
if (typeof callback == "function") callback("");
}
});
};
//判断当前邀请码状态,分辨邀请者身份
as.checkResourceId = function (resourceId, callback) {
as.co.checkAppCooperationInfoSelfOrNot({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (res && res.success) {
//res.content :"not exist"非邀请链接;"true"自己的分享链接;"false"他人的分享链接
if (typeof callback == "function") callback(res.content);
} else {
if (typeof callback == "function") callback("not exist");
}
},
"error": function (res) {
if (typeof callback == "function") callback("not exist");
}
});
};
//读取用户所有邀请码
as.getResourceId = function (callback) {
as.co.queryCurrentUserAppCooperationInfoIdList({
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback([]);
}
});
};
//读取当前邀请码信息
as.getUserInfoByResourceId = function (resourceId, callback) {
as.co.queryCurrentAppCooperationInfo({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
//为邀请码点赞
as.addPraise = function (resourceId, callback) {
as.co.praise({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(false);
}
});
};
//读取邀请码的点赞数
as.getPraise = function (resourceId, callback) {
as.co.getPraiseRecordTotalByResourceId({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(0);
}
});
};
//判断用户是否为邀请码点赞
as.checkUserPraise = function (resourceId, callback) {
as.co.checkCurrentUserPraiseOrNot({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(false);
}
});
};
as.getPraiseLog = function (resourceId, page, size, callback) {
as.co.queryPraiseRecordListByResourceId({
"param": {
"resourceId": resourceId,
"page": page,
"size": size
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback([]);
}
});
};
//为邀请码评论
as.addComment = function (resourceId, content, callback) {
as.co.comment({
"param": {
"resourceId": resourceId,
"content": content,
"parentId": "",
"remark": ""
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
//评论列表
as.queryCommentList = function (resourceId, page, size, callback) {
as.co.queryAppCooperationInfoCommentRecordList({
"param": {
"resourceId": resourceId,
"page": page,
"size": size,
"ascending": false
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback([]);
}
});
};
//读取邀请码评论数
as.queryCommentCount = function (resourceId, callback) {
as.co.getAppCooperationInfoCommentRecordTotal({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(0);
}
});
};
//当前用户对邀请码的评论总数
as.queryCommentCountByUser = function (resourceId, callback) {
as.co.getCurrentUserAppCooperationInfoCommentRecordTotal({
"param": {
"resourceId": resourceId
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(0);
}
});
};
/*------------------协作相关 end-----------------------*/
/*------------------排行榜相关 start---------------------*/
/*
* 提交成绩
* rankName : 排行榜名字
* score : 游戏分数
* spendTime : 游戏耗时
*/
as.rankSubmitScore = function (score, spendTime, callback) {
as.rank.saveRankScore({
"param": {
"rankName": as.rankName,
"score": score,
"spendTime": spendTime
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
//查询排行榜(包含当前用户的排行记录)
as.rankQueryRankList = function (page, size, callback) {
as.rank.queryRankList({
"param": {
"rankName": as.rankName,
"selfInclude": true,
"page": page,
"size": size
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
//查询当前用户排名
as.rankQueryUserRankRecord = function (callback) {
as.rank.queryUserRankRecord({
"param": {
"rankName": as.rankName
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
//查询当前用户的记录
as.rankQueryRankHistory = function (callback) {
as.rank.queryRankHistory({
"param": {
"rankName": as.rankName
},
"success": function (res) {
console.log(res, "rankQueryUserRankRecord success");
if (typeof callback == "function") callback(res);
},
"error": function (res) {
console.log(res.response, "rankQueryUserRankRecord error");
if (typeof callback == "function") callback(null);
}
});
};
/*------------------排行榜相关 end-----------------------*/
/*------------------派加接口相关 start---------------------*/
//读取用户积分
as.getIntegral = function (callback) {
as.piplus.readUserIntegral({
"success": function (res) {
if (res && res.integral) {
if (typeof callback == "function") callback(res.integral);
} else {
if (typeof callback == "function") callback(0);
}
},
"error": function (res) {
if (typeof callback == "function") callback(0);
}
});
};
//判断当前用户是否会员
as.checkMember = function (callback) {
as.piplus.isMember({
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback({
"isMember": false,
"integral": 0
});
}
});
};
//查询当前用户会员信息
as.readMember = function (callback) {
as.piplus.readMember({
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback({
"status": false
});
}
});
};
//同步会员信息
as.commonSaveUserInfo = function (user_name, mobile, province, city, area, address, birthday, tags, callback) {
as.piplus.commonSaveUserInfo({
"param": {
"user_name": user_name,
"mobile": mobile,
"province": province,
"city": city,
"area": area,
"address": address,
"birthday": birthday,
"tags": tags
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback({
"status": false
});
}
});
};
//获取省份
as.getProvinces = function (callback) {
as.piplus.getProvinces({
"success": function (res) {
if (res.http_status && res.errmsg == "success") {
if (typeof callback == "function") callback(res.data);
} else {
if (typeof callback == "function") callback([]);
}
},
"error": function (res) {
if (typeof callback == "function") callback([]);
}
});
};
//获取城市
as.getCity = function (regionId, callback) {
as.piplus.getCity({
"param": {
"regionId": regionId
},
"success": function (res) {
if (res.http_status && res.errmsg == "success") {
if (typeof callback == "function") callback(res.data);
} else {
if (typeof callback == "function") callback([]);
}
},
"error": function (res) {
if (typeof callback == "function") callback([]);
}
});
};
//获取区域
as.getArea = function (regionId, callback) {
as.piplus.getCity({
"param": {
"regionId": regionId
},
"success": function (res) {
if (res.http_status && res.errmsg == "success") {
if (typeof callback == "function") callback(res.data);
} else {
if (typeof callback == "function") callback([]);
}
},
"error": function (res) {
if (typeof callback == "function") callback([]);
}
});
};
/*------------------派加接口相关 end-----------------------*/
/*------------------图片路径转换 start---------------------*/
as.getJpgCdnUrl = function (imgUrl, callback) {
as.jpgCdn.getJpgCDNUrl({
"param": {
"imgUrl": imgUrl
},
"success": function (res) {
if (res && res.success) {
if (typeof callback == "function") callback(res.content);
} else {
if (typeof callback == "function") callback(null);
}
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
as.getCdnImg = function (imgName, callback) {
if (typeof callback == "function")
callback(as.jpgCdn.getCDNImg(imgName));
};
as.designImg = function (imgName, height, callback) {
if (typeof callback == "function")
callback(as.jpgCdn.designImg(imgName, height));
};
/*------------------图片路径转换 end-----------------------*/
/*------------------上传照片相关 start---------------------*/
as.uploadBase64 = function (base64, callback) {
as.file.uploadBase64(base64, as.AppID, {
"success": function (res) {
var obj = {
"result": true,
"data": res
};
if (typeof callback == "function") callback(obj);
},
"error": function (res) {
if (typeof callback == "function") callback({
"result": false
});
}
});
};
/*------------------上传照片相关 end-----------------------*/
/*------------------微信语音 start---------------------*/
//开始录音
as.startRecord = function (callback) {
if (typeof wx != "undefined" && wx != void 0) {
var completeFn = function (res) {
if (res["errMsg"] == "startRecord:ok") {
if (typeof callback == "function") callback(true);
}
}
wx.startRecord({
cancel: function () {
alert('用户拒绝授权录音');
if (typeof callback == "function") callback(false);
},
complete: completeFn,
});
// if (typeof callback == "function") callback(true);
} else {
if (typeof callback == "function") callback(false);
}
};
//停止录音
as.stopRecord = function (callback) {
if (typeof wx != "undefined" && wx != void 0) {
wx.stopRecord({
success: function (res) {
if (typeof callback == "function") callback(res.localId);
}
});
} else {
if (typeof callback == "function") callback("");
}
};
//上传语音到微信服务器
as.uploadVoice = function (localId, callback) {
if (typeof wx != "undefined" && wx != void 0 && localId != "") {
wx.uploadVoice({
"localId": localId, // 需要上传的音频的本地ID,由stopRecord接口获得
"isShowProgressTips": 1, // 默认为1,显示进度提示
"success": function (res) {
if (typeof callback == "function") callback(res.serverId);
}
});
} else {
if (typeof callback == "function") callback("");
}
};
//下载微信服务语音到本地
as.downloadVoice = function (serverId, callback) {
if (typeof wx != "undefined" && wx != void 0 && serverId != "") {
wx.downloadVoice({
"serverId": serverId, // 需要下载的音频的服务器端ID,由uploadVoice接口获得
"isShowProgressTips": 1, // 默认为1,显示进度提示
"success": function (res) {
if (res && res.localId) {
if (typeof callback === "function") callback(res.localId);
} else {
if (typeof callback === "function") callback("");
}
}
});
} else {
if (typeof callback === "function") callback("");
}
};
//保存录音
as.saveUserVoice = function (vid, serverId, callback) {
as.wxMultimedia.record({
"param": {
"vId": vid,
"serverId": serverId
},
"success": function (res) {
if (res && res.code == 10000) {
if (typeof callback == "function") callback(true);
} else {
if (typeof callback == "function") callback(false);
}
},
"error": function (res) {
if (typeof callback == "function") callback(false);
}
});
};
//读取单个录音
as.getUserVoice = function (vid, callback) {
try {
as.wxMultimedia.get({
"param": {
"vId": vid
},
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
} catch (e) {
if (typeof callback == "function") callback(null);
}
};
//播放声音
as.playVoice = function (localId, voiceStatus, voiceUrl, serverId, callback) {
if (localId != "") {
as.playRecord(localId, function () {
if (typeof callback == "function") callback(true, null);
});
} else if ((voiceStatus == "CONVERT_SUCCESS" || voiceStatus == 6) && voiceUrl != "") {
var dom = document.getElementsByTagName("body")[0];
var nDiv = document.createElement("div");
nDiv.style.width = "0px";
nDiv.style.height = "0px";
nDiv.style.position = "absolute";
var sound = document.createElement("audio");
sound.src = voiceUrl;
//sound.preload= "preload";
//sound.src = src;
nDiv.appendChild(sound);
dom.appendChild(nDiv);
sound.addEventListener("ended", function () {
if (typeof callback === "function") callback(true, null);
}, false);
sound.play();
} else if (serverId != "") {
as.downloadVoice(serverId, function (res) {
as.playRecord(res, function () {
if (typeof callback == "function") callback(true, res);
});
});
} else {
if (typeof callback === "function") callback(false, null);
}
};
//播放录音(微信)
as.playRecord = function (localId, callback) {
if (typeof wx != "undefined" && wx != void 0 && localId != "") {
wx.playVoice({
localId: localId // 需要播放的音频的本地ID,由stopRecord接口获得
});
wx.onVoicePlayEnd({
success: function (res) {
if (typeof callback === "function") callback(true);
}
});
} else {
if (typeof callback === "function") callback(false);
}
};
//停止播放录音(微信)
as.stopVoice = function (localId) {
if (typeof wx != "undefined" && wx != void 0 && localId != "") {
wx.stopVoice({
localId: localId
});
}
};
/*------------------微信语音 end---------------------*/
/*------------------其它 start---------------------*/
/*
* tableName 要存的表的名字
* data 为字典结构
* 例如 data = {}
* data["key"] = value;
*/
as.saveTable = function (tableName, value, callback) {
var table = HDP.getTable(tableName);
for (var key in value) {
table.set(key, value[key]);
}
table.save({
"success": function (res) {
if (typeof callback == "function") callback(res);
},
"error": function (res) {
if (typeof callback == "function") callback(null);
}
});
};
/*------------------其它 end-----------------------*/
/*------------------ 以下为定制化接口 ---------------------*/
as.bizInterface = null;
//多奖池抽奖
as.bizManyLottery = function (appId, callback) {
if (as.bizInterface == null) {
as.bizInterface = HDP.getBizInterface();
}
if (appId == undefined || appId == null || appId == "") {
if (typeof callback == "function") callback({
"result": false
});
}
as.bizInterface.manyLottery({
"param": {
"appId": appId
},
"success": function (res) {
if (res && res.success && res.content) {
if (typeof callback == "function") callback(res.content);
} else {
if (typeof callback == "function") callback({
"result": false
});
}
},
"error": function (res) {
if (typeof callback == "function") callback({
"result": false
});
}
});
};
\ No newline at end of file
let global_gzh_name = "袋鼠妈妈学堂";
let global_gzh_wxAppId = "wxaf7d9b7414c6df11";
let global_register_redirect = false;
// let global_gzh_name = "安敏健行";
// let global_gzh_wxAppId = "wx3a4821f58cc1ded7";
// let global_register_redirect = "https://nutwpgateway.novaetech.cn/wx/oauth2/authorize?brandId=17378876&scope=snsapi_base&url=http%3A%2F%2Fh5.novaetech.cn%2F%23%2Fshowqrcode";
\ No newline at end of file
This diff could not be displayed because it is too large.
!function(e,n){"function"==typeof define&&(define.amd||define.cmd)?define(function(){return n(e)}):n(e,!0)}(this,function(e,n){function i(n,i,t){e.WeixinJSBridge?WeixinJSBridge.invoke(n,o(i),function(e){c(n,e,t)}):u(n,t)}function t(n,i,t){e.WeixinJSBridge?WeixinJSBridge.on(n,function(e){t&&t.trigger&&t.trigger(e),c(n,e,i)}):t?u(n,t):u(n,i)}function o(e){return e=e||{},e.appId=P.appId,e.verifyAppId=P.appId,e.verifySignType="sha1",e.verifyTimestamp=P.timestamp+"",e.verifyNonceStr=P.nonceStr,e.verifySignature=P.signature,e}function r(e){return{timeStamp:e.timestamp+"",nonceStr:e.nonceStr,package:e.package,paySign:e.paySign,signType:e.signType||"SHA1"}}function a(e){return e.postalCode=e.addressPostalCode,delete e.addressPostalCode,e.provinceName=e.proviceFirstStageName,delete e.proviceFirstStageName,e.cityName=e.addressCitySecondStageName,delete e.addressCitySecondStageName,e.countryName=e.addressCountiesThirdStageName,delete e.addressCountiesThirdStageName,e.detailInfo=e.addressDetailInfo,delete e.addressDetailInfo,e}function c(e,n,i){"openEnterpriseChat"==e&&(n.errCode=n.err_code),delete n.err_code,delete n.err_desc,delete n.err_detail;var t=n.errMsg;t||(t=n.err_msg,delete n.err_msg,t=s(e,t),n.errMsg=t),(i=i||{})._complete&&(i._complete(n),delete i._complete),t=n.errMsg||"",P.debug&&!i.isInnerInvoke&&alert(JSON.stringify(n));var o=t.indexOf(":");switch(t.substring(o+1)){case"ok":i.success&&i.success(n);break;case"cancel":i.cancel&&i.cancel(n);break;default:i.fail&&i.fail(n)}i.complete&&i.complete(n)}function s(e,n){var i=e,t=h[i];t&&(i=t);var o="ok";if(n){var r=n.indexOf(":");"confirm"==(o=n.substring(r+1))&&(o="ok"),"failed"==o&&(o="fail"),-1!=o.indexOf("failed_")&&(o=o.substring(7)),-1!=o.indexOf("fail_")&&(o=o.substring(5)),"access denied"!=(o=(o=o.replace(/_/g," ")).toLowerCase())&&"no permission to execute"!=o||(o="permission denied"),"config"==i&&"function not exist"==o&&(o="ok"),""==o&&(o="fail")}return n=i+":"+o}function d(e){if(e){for(var n=0,i=e.length;n<i;++n){var t=e[n],o=g[t];o&&(e[n]=o)}return e}}function u(e,n){if(!(!P.debug||n&&n.isInnerInvoke)){var i=h[e];i&&(e=i),n&&n._complete&&delete n._complete,console.log('"'+e+'",',n||"")}}function l(e){if(!(I||T||P.debug||C<"6.0.2"||x.systemType<0)){var n=new Image;x.appId=P.appId,x.initTime=V.initEndTime-V.initStartTime,x.preVerifyTime=V.preVerifyEndTime-V.preVerifyStartTime,b.getNetworkType({isInnerInvoke:!0,success:function(e){x.networkType=e.networkType;var i="https://open.weixin.qq.com/sdk/report?v="+x.version+"&o="+x.isPreVerifyOk+"&s="+x.systemType+"&c="+x.clientVersion+"&a="+x.appId+"&n="+x.networkType+"&i="+x.initTime+"&p="+x.preVerifyTime+"&u="+x.url;n.src=i}})}}function p(){return(new Date).getTime()}function f(n){w&&(e.WeixinJSBridge?n():S.addEventListener&&S.addEventListener("WeixinJSBridgeReady",n,!1))}function m(){b.invoke||(b.invoke=function(n,i,t){e.WeixinJSBridge&&WeixinJSBridge.invoke(n,o(i),t)},b.on=function(n,i){e.WeixinJSBridge&&WeixinJSBridge.on(n,i)})}if(!e.jWeixin){var g={config:"preVerifyJSAPI",onMenuShareTimeline:"menu:share:timeline",onMenuShareAppMessage:"menu:share:appmessage",onMenuShareQQ:"menu:share:qq",onMenuShareWeibo:"menu:share:weiboApp",onMenuShareQZone:"menu:share:QZone",previewImage:"imagePreview",getLocation:"geoLocation",openProductSpecificView:"openProductViewWithPid",addCard:"batchAddCard",openCard:"batchViewCard",chooseWXPay:"getBrandWCPayRequest",openEnterpriseRedPacket:"getRecevieBizHongBaoRequest",startSearchBeacons:"startMonitoringBeacons",stopSearchBeacons:"stopMonitoringBeacons",onSearchBeacons:"onBeaconsInRange",consumeAndShareCard:"consumedShareCard",openAddress:"editAddress"},h=function(){var e={};for(var n in g)e[g[n]]=n;return e}(),S=e.document,y=S.title,v=navigator.userAgent.toLowerCase(),_=navigator.platform.toLowerCase(),I=!(!_.match("mac")&&!_.match("win")),T=-1!=v.indexOf("wxdebugger"),w=-1!=v.indexOf("micromessenger"),k=-1!=v.indexOf("android"),M=-1!=v.indexOf("iphone")||-1!=v.indexOf("ipad"),C=function(){var e=v.match(/micromessenger\/(\d+\.\d+\.\d+)/)||v.match(/micromessenger\/(\d+\.\d+)/);return e?e[1]:""}(),V={initStartTime:p(),initEndTime:0,preVerifyStartTime:0,preVerifyEndTime:0},x={version:1,appId:"",initTime:0,preVerifyTime:0,networkType:"",isPreVerifyOk:1,systemType:M?1:k?2:-1,clientVersion:C,url:encodeURIComponent(location.href)},P={},A={_completes:[]},B={state:0,data:{}};f(function(){V.initEndTime=p()});var b={config:function(e){P=e,u("config",e);var n=!1!==P.check;f(function(){if(n)i(g.config,{verifyJsApiList:d(P.jsApiList)},function(){A._complete=function(e){V.preVerifyEndTime=p(),B.state=1,B.data=e},A.success=function(e){x.isPreVerifyOk=0},A.fail=function(e){A._fail?A._fail(e):B.state=-1};var e=A._completes;return e.push(function(){l()}),A.complete=function(n){for(var i=0,t=e.length;i<t;++i)e[i]();A._completes=[]},A}()),V.preVerifyStartTime=p();else{B.state=1;for(var e=A._completes,t=0,o=e.length;t<o;++t)e[t]();A._completes=[]}}),P.beta&&m()},ready:function(e){0!=B.state?e():(A._completes.push(e),!w&&P.debug&&e())},error:function(e){C<"6.0.2"||(-1==B.state?e(B.data):A._fail=e)},checkJsApi:function(e){var n=function(e){var n=e.checkResult;for(var i in n){var t=h[i];t&&(n[t]=n[i],delete n[i])}return e};i("checkJsApi",{jsApiList:d(e.jsApiList)},(e._complete=function(e){if(k){var i=e.checkResult;i&&(e.checkResult=JSON.parse(i))}e=n(e)},e))},onMenuShareTimeline:function(e){t(g.onMenuShareTimeline,{complete:function(){i("shareTimeline",{title:e.title||y,desc:e.title||y,img_url:e.imgUrl||"",link:e.link||location.href,type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareAppMessage:function(e){t(g.onMenuShareAppMessage,{complete:function(n){"favorite"===n.scene?i("sendAppMessage",{title:e.title||y,desc:e.desc||"",link:e.link||location.href,img_url:e.imgUrl||"",type:e.type||"link",data_url:e.dataUrl||""}):i("sendAppMessage",{title:e.title||y,desc:e.desc||"",link:e.link||location.href,img_url:e.imgUrl||"",type:e.type||"link",data_url:e.dataUrl||""},e)}},e)},onMenuShareQQ:function(e){t(g.onMenuShareQQ,{complete:function(){i("shareQQ",{title:e.title||y,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareWeibo:function(e){t(g.onMenuShareWeibo,{complete:function(){i("shareWeiboApp",{title:e.title||y,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},onMenuShareQZone:function(e){t(g.onMenuShareQZone,{complete:function(){i("shareQZone",{title:e.title||y,desc:e.desc||"",img_url:e.imgUrl||"",link:e.link||location.href},e)}},e)},startRecord:function(e){i("startRecord",{},e)},stopRecord:function(e){i("stopRecord",{},e)},onVoiceRecordEnd:function(e){t("onVoiceRecordEnd",e)},playVoice:function(e){i("playVoice",{localId:e.localId},e)},pauseVoice:function(e){i("pauseVoice",{localId:e.localId},e)},stopVoice:function(e){i("stopVoice",{localId:e.localId},e)},onVoicePlayEnd:function(e){t("onVoicePlayEnd",e)},uploadVoice:function(e){i("uploadVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadVoice:function(e){i("downloadVoice",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},translateVoice:function(e){i("translateVoice",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},chooseImage:function(e){i("chooseImage",{scene:"1|2",count:e.count||9,sizeType:e.sizeType||["original","compressed"],sourceType:e.sourceType||["album","camera"]},(e._complete=function(e){if(k){var n=e.localIds;try{n&&(e.localIds=JSON.parse(n))}catch(e){}}},e))},previewImage:function(e){i(g.previewImage,{current:e.current,urls:e.urls},e)},uploadImage:function(e){i("uploadImage",{localId:e.localId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},downloadImage:function(e){i("downloadImage",{serverId:e.serverId,isShowProgressTips:0==e.isShowProgressTips?0:1},e)},getNetworkType:function(e){var n=function(e){var n=e.errMsg;e.errMsg="getNetworkType:ok";var i=e.subtype;if(delete e.subtype,i)e.networkType=i;else{var t=n.indexOf(":"),o=n.substring(t+1);switch(o){case"wifi":case"edge":case"wwan":e.networkType=o;break;default:e.errMsg="getNetworkType:fail"}}return e};i("getNetworkType",{},(e._complete=function(e){e=n(e)},e))},openLocation:function(e){i("openLocation",{latitude:e.latitude,longitude:e.longitude,name:e.name||"",address:e.address||"",scale:e.scale||28,infoUrl:e.infoUrl||""},e)},getLocation:function(e){e=e||{},i(g.getLocation,{type:e.type||"wgs84"},(e._complete=function(e){delete e.type},e))},hideOptionMenu:function(e){i("hideOptionMenu",{},e)},showOptionMenu:function(e){i("showOptionMenu",{},e)},closeWindow:function(e){i("closeWindow",{},e=e||{})},hideMenuItems:function(e){i("hideMenuItems",{menuList:e.menuList},e)},showMenuItems:function(e){i("showMenuItems",{menuList:e.menuList},e)},hideAllNonBaseMenuItem:function(e){i("hideAllNonBaseMenuItem",{},e)},showAllNonBaseMenuItem:function(e){i("showAllNonBaseMenuItem",{},e)},scanQRCode:function(e){i("scanQRCode",{needResult:(e=e||{}).needResult||0,scanType:e.scanType||["qrCode","barCode"]},(e._complete=function(e){if(M){var n=e.resultStr;if(n){var i=JSON.parse(n);e.resultStr=i&&i.scan_code&&i.scan_code.scan_result}}},e))},openAddress:function(e){i(g.openAddress,{},(e._complete=function(e){e=a(e)},e))},openProductSpecificView:function(e){i(g.openProductSpecificView,{pid:e.productId,view_type:e.viewType||0,ext_info:e.extInfo},e)},addCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;o<r;++o){var a=n[o],c={card_id:a.cardId,card_ext:a.cardExt};t.push(c)}i(g.addCard,{card_list:t},(e._complete=function(e){var n=e.card_list;if(n){for(var i=0,t=(n=JSON.parse(n)).length;i<t;++i){var o=n[i];o.cardId=o.card_id,o.cardExt=o.card_ext,o.isSuccess=!!o.is_succ,delete o.card_id,delete o.card_ext,delete o.is_succ}e.cardList=n,delete e.card_list}},e))},chooseCard:function(e){i("chooseCard",{app_id:P.appId,location_id:e.shopId||"",sign_type:e.signType||"SHA1",card_id:e.cardId||"",card_type:e.cardType||"",card_sign:e.cardSign,time_stamp:e.timestamp+"",nonce_str:e.nonceStr},(e._complete=function(e){e.cardList=e.choose_card_info,delete e.choose_card_info},e))},openCard:function(e){for(var n=e.cardList,t=[],o=0,r=n.length;o<r;++o){var a=n[o],c={card_id:a.cardId,code:a.code};t.push(c)}i(g.openCard,{card_list:t},e)},consumeAndShareCard:function(e){i(g.consumeAndShareCard,{consumedCardId:e.cardId,consumedCode:e.code},e)},chooseWXPay:function(e){i(g.chooseWXPay,r(e),e)},openEnterpriseRedPacket:function(e){i(g.openEnterpriseRedPacket,r(e),e)},startSearchBeacons:function(e){i(g.startSearchBeacons,{ticket:e.ticket},e)},stopSearchBeacons:function(e){i(g.stopSearchBeacons,{},e)},onSearchBeacons:function(e){t(g.onSearchBeacons,e)},openEnterpriseChat:function(e){i("openEnterpriseChat",{useridlist:e.userIds,chatname:e.groupName},e)}};return n&&(e.wx=e.jWeixin=b),b}});
\ No newline at end of file
......@@ -6,10 +6,6 @@ import Router from '../router'
// Toast
// } from 'vant';
function Toast(msg) {
console.log("msg:", msg);
}
// axios的默认url
// axios.defaults.baseURL = ""
......@@ -54,7 +50,7 @@ axios.interceptors.response.use(
store.removeSession();
store.saveRedirectUrl();
Router.push("/");
}
}
return Promise.reject(response);
}
} else {
......@@ -192,21 +188,21 @@ export const formdata = params => {
export const request = {
post(url, data) {
return axios.post(`${requestDomain}${url}`, data);
return axios.post(`${base}${url}`, data);
},
get(url, data) {
return axios.get(`${requestDomain}${url}`, { params: data });
return axios.get(`${base}${url}`, { params: data });
},
form(url, params) {
let formData = new FormData(); //使用formData对象
for (let key in params) {
formData.append(key, params[key]);
}
let requestUrl = url.indexOf("://") >= 0 ? `${url}` : `${requestDomain}${url}`;
let requestUrl = url.indexOf("://") >= 0 ? `${url}` : `${base}${url}`;
return axios.post(requestUrl, formData, formDataHeaders)
},
build(url, params){
let fullUrl = `${requestDomain}${url}`;
let fullUrl = `${base}${url}`;
let split = "";
for(let key in params){
if(split){
......
<template>
<van-overlay :show="show" >
</van-overlay>
<van-popup v-model="data.show">
<div class="model">
<div class="model-close" @click="modelCloseHandler"></div>
<div class="model-content">
<div class="model-head-line"></div>
<div class="model-title">{{data.title}}</div>
<div class="successModel" v-if="data.index == 'default'">
<div class="model-data">{{data.content}}</div>
<div v-if="data.btnShow" class="sys-btn-02" @click="modelBtnClickHandler">{{data.btnText}}</div>
<div
v-if="data.labelBtnShow"
class="label-btn"
@click="labelBtnClickHandler"
>{{data.labelBtnText}}</div>
<div class="model-bottom-line"></div>
</div>
</div>
</div>
</van-popup>
</template>
<script>
import Vue from "vue";
import { Overlay } from "vant";
Vue.use(Overlay);
import { Popup } from "vant";
Vue.use(Popup);
export default {
props: ["value"],
data() {
return {
model: this.value,
show: false
data: this.value
};
},
methods: {},
created() {}
methods: {
modelCloseHandler() {
this.$emit("close");
this.data.show = false;
},
modelBtnClickHandler() {
this.data.show = false;
typeof this.data.confirmHandler == "function" &&
this.data.confirmHandler();
},
labelBtnClickHandler() {
this.data.show = false;
typeof this.data.labelBtnHandler == "function" &&
this.data.labelBtnHandler();
}
},
created() {
this.data = this.data
? this.data
: {
title: "",
description: "",
show: false,
index: "default",
btnShow: false,
btnText: "",
confirmHandler: null,
labelBtnShow: false,
labelBtnText: "",
labelBtnHandler: null
};
}
};
</script>
<style lang="less" scoped>
.van-popup {
background-color: transparent;
top: 40%;
}
.model {
display: flex;
width: 480px;
min-height: 576px;
flex-direction: column;
align-items: flex-end;
}
.model-head-line {
height: 50px;
background-color: transparent;
}
.model-bottom-line {
height: 50px;
background-color: transparent;
}
.model-close {
width: 64px;
height: 116px;
background: url(../../assets/imgs/model-close.png);
background-size: 100%;
}
.model-content {
width: 480px;
min-height: 460px;
height: auto;
background: url(../../assets/imgs/model-bottom.png) no-repeat;
background-size: 100% auto;
background-position: bottom;
border-radius: 30px;
background-color: #fff;
}
.model-title {
font-size: 45px;
font-weight: bold;
}
.model-data {
font-size: 30px;
margin: 50px auto 70px auto;
width: 400px;
text-align: center;
}
.sys-btn-02 {
width: 300px;
font-size: 30px;
line-height: 80px;
}
.label-btn {
font-size: 26px;
text-align: center;
}
</style>
......
......@@ -56,11 +56,15 @@ export default {
},
login() {
httpPost({ url: urls.login, data: this.loginParam }).then(res => {
store.putSession(res.sessionId);
let path = store.getRedirectUrl();
path = !path ? "/index" : path;
store.delRedirectUrl();
this.$router.push(path);
if (!res.sessionId) {
store.toWxLogin();
} else {
store.putSession(res.sessionId);
let path = store.getRedirectUrl();
path = !path ? "/index" : path;
store.delRedirectUrl();
this.$router.push(path);
}
});
}
},
......
......@@ -185,6 +185,8 @@ export default {
});
httpPost({ url: urls.submit, data: this.formData }).then(res => {
Toast.clear();
this.formData.worksCode = res;
console.log("submit === =", res);
this.$emit("submit", res);
});
}
......@@ -314,7 +316,6 @@ export default {
color: #4f9984;
font-size: 18px;
}
}
.view-btn-group {
......
......@@ -57,15 +57,17 @@
</template>
<script>
let urls = {};
let urls = {
praise: "/jiajiaCHApi/app/works/praise"
};
import { httpGet, httpPost } from "@/api/fetch-api";
import { request } from "@/api/fetch-api";
import Vue from "vue";
import { Toast } from "vant";
import { Popup } from "vant";
import { Swipe, SwipeItem } from "vant";
Vue.use(Popup);
Vue.use(Swipe).use(SwipeItem);
Vue.use(Toast);
export default {
......@@ -81,9 +83,28 @@ export default {
},
selfPraiseHandler() {
// 自己点赞
let data = {
worksCode: this.formData.worksCode
};
Toast.loading({
mask: true,
message: "数据提交..."
});
request
.post(urls.praise, data)
.then(res => {
Toast.clear();
this.$emit("praiseSuccess")
})
.catch(res => {
let msg = res.data.errMsg;
Toast(msg);
});
},
showShareHandler() {
// 出现分享层
this.$emit("showShare")
console.log("show share")
}
},
created() {
......
......@@ -2,16 +2,26 @@
<div class="home">
<div class="head-leap"></div>
<ViewModel v-model="formData" v-if="init && !formEdit" v-on:edit="formEdit=true"></ViewModel>
<EditModel v-model="formData" v-if="init && formEdit" v-on:submit="initActivity"></EditModel>
<ViewModel
v-model="formData"
v-if="init && !formEdit"
v-on:edit="formEdit=true"
v-on:praiseSuccess="showPraiseSuccessModel"
v-on:showShare="shareModelVisiable=true"
></ViewModel>
<EditModel v-model="formData" v-if="init && formEdit" v-on:submit="showSuccessModel"></EditModel>
<div class="bottom-line"></div>
<bottom-tool v-model="activityIndex"></bottom-tool>
<!-- <van-popup class="messagePopue" v-model="successModelVisiable" :close-on-click-overlay="false">
<div></div>
</van-popup>-->
<biz-model v-model="model"></biz-model>
<!-- 分享蒙层 -->
<div class="shareModel" v-if="shareModelVisiable" @click="shareModelVisiable = false">
<div class="shareModelContainer">
<div class="shareModelMask"></div>
<div class="shareIcon"></div>
</div>
</div>
</div>
</template>
......@@ -22,6 +32,7 @@ let urls = {
};
import BottomTool from "@/components/bottom-tools/bottom-tools";
import BizModel from "@/components/biz-model/biz-model";
import EditModel from "./components/EditModel";
import ViewModel from "./components/ViewModel";
......@@ -30,14 +41,8 @@ import AreaList from "@/api/area";
import Vue from "vue";
import { Toast } from "vant";
import { Area } from "vant";
import { Popup } from "vant";
import { Swipe, SwipeItem } from "vant";
Vue.use(Popup);
Vue.use(Area);
Vue.use(Toast);
Vue.use(Swipe).use(SwipeItem);
export default {
name: "home",
......@@ -47,8 +52,9 @@ export default {
formEdit: false,
init: false,
isMy: 1,
successModelVisiable: true,
shareModelVisiable: false,
formData: {
worksCode: "",
name: "",
province: "",
provinceCode: "",
......@@ -59,6 +65,18 @@ export default {
parentName: "",
parentMobile: "",
worksList: []
},
model: {
show: false,
title: "",
content: "",
index: "default",
btnShow: false,
btnText: "",
confirmHandler: null,
labelBtnShow: false,
labelBtnText: "",
labelBtnHandler: null
}
};
},
......@@ -78,13 +96,57 @@ export default {
} else {
this.formEdit = false;
}
this.initShare();
});
},
showSuccessModel() {
this.model.title = "温馨提示";
this.model.content = "报名已成功!";
this.model.index = "default";
this.model.btnShow = true;
this.model.btnText = "查看我的主页";
this.model.show = true;
let that = this;
this.model.confirmHandler = function() {
that.initActivity();
};
},
showPraiseSuccessModel() {
this.model.show = true;
this.model.title = "点赞成功";
this.model.content = "您已获得一次抽奖机会";
this.model.btnShow = true;
this.model.btnText = "前往抽奖";
let that = this;
this.model.confirmHandler = function() {
that.$router.push("/draw");
};
this.model.labelBtnShow = true;
this.model.labelBtnText = "查看个人主页";
this.model.labelBtnHandler = function() {
that.initActivity();
};
},
initShare() {
let link = location.origin + location.pathname;
if (this.formData.worksCode) {
link += "?worksCode=" + this.formData.worksCode;
}
let desc = this.formData.profile || null;
let imgurl =
this.formData.worksList.length > 0
? this.formData.worksList[0].worksUrl
: null;
as.setShare(link, null, desc, imgurl);
}
},
components: {
BottomTool,
EditModel,
ViewModel
ViewModel,
BizModel
},
created() {
this.initActivity();
......@@ -113,4 +175,37 @@ export default {
height: 250px;
background-color: transparent;
}
.shareModel {
position: fixed;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
z-index: 9999;
}
.shareModelContainer {
position: relative;
height: 100%;
width: 100%;
}
.shareModelMask {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.7);
}
.shareIcon {
position: absolute;
top: 0px;
right: 30px;
width: 425px;
height: 220px;
background: url(../../assets/imgs/model-share-tip.png) no-repeat;
background-size: 100%;
}
</style>
......