最新要闻
- 微资讯!壮观!马斯克星链卫星驶过西班牙夜空:宛若空中列车
- 【世界聚看点】小学生满分作文跑题老师含泪打5分:把“悔”看成“梅”
- 环球热资讯!特斯拉京东旗舰店开业:269元的U盘上架
- 首发16.2元:《仙剑奇侠传7》DLC《人间如梦》正式上线
- ChatGPT版必应发飙!怒斥人类:放尊重些
- 7万起售 五菱缤果内饰官图发布:同级无敌手
- 世界上最轻VR头显面世:仅重127克 5K分辨率
- 环球新消息丨苹果汽车奇瑞造?“果链一哥”立讯与奇瑞签署合作 联手造车
- 当前动态:法拉第未来:预计FF 91将于4月底交付 但有个前提
- 不用第三方插件了:微软计划为Edge加入鼠标手势功能
- qq空间主人寄语怎么删除?qq空间主人寄语大集合
- 开学的歌曲有哪些?开学的趣事作文模板
- 熟悉的人是什么意思?关于我最熟悉的人作文合集
- 皮脂腺分泌旺盛是什么原因?皮脂腺分泌旺盛怎么解决?
- 代表月亮消灭你是什么意思?代表月亮消灭你是谁的经典台词?
- 速看:口味地道 丰富配料!渣渣灰南昌拌粉好价:4.9元/盒
广告
手机
iphone11大小尺寸是多少?苹果iPhone11和iPhone13的区别是什么?
警方通报辅警执法直播中被撞飞:犯罪嫌疑人已投案
- iphone11大小尺寸是多少?苹果iPhone11和iPhone13的区别是什么?
- 警方通报辅警执法直播中被撞飞:犯罪嫌疑人已投案
- 男子被关545天申国赔:获赔18万多 驳回精神抚慰金
- 3天内26名本土感染者,辽宁确诊人数已超安徽
- 广西柳州一男子因纠纷杀害三人后自首
- 洱海坠机4名机组人员被批准为烈士 数千干部群众悼念
家电
快讯:Unity 转小游戏
填写appid 和游戏资源位置
(相关资料图)
在导出的项目里可以修改游戏资源位置 两个目录 minigame 是小程序打开的目录 webgl 是要下载的的资源 下载一个http 服务器就有了
和JS交互 大部分js 功能都被封装到了C# 只用做少量的即可
在wx-wasm-sdk 下得 Plugins 目录下新建文件Channel.jslib
mergeInto(LibraryManager.library, { WebChannelLogin: function () { window.WXWASMSDK.WebChannelLogin(); }, WebTrackEvent: function(platName,eventName){ window.WXWASMSDK.WebTrackEvent(_WXPointer_stringify_adaptor(platName),_WXPointer_stringify_adaptor(eventName)); }, WebPayItem: function(arg){ window.WXWASMSDK.WebPayItem(_WXPointer_stringify_adaptor(arg)); }, WebCallChannelVoidFunWithArg: function(name, arg) { window.WXWASMSDK.WebCallChannelVoidFunWithArg(_WXPointer_stringify_adaptor(name),_WXPointer_stringify_adaptor(arg)); }, WebSetUserData: function(arg){ window.WXWASMSDK.WebSetUserData(_WXPointer_stringify_adaptor(arg)); }, WebTanWanEvent: function(name, arg){window.WXWASMSDK.WebTanWanEvent(_WXPointer_stringify_adaptor(name),_WXPointer_stringify_adaptor(arg)); },});
他其实和Lua 的全表有点像
新建 apps文件
import { appEntity } from "./app-entity";import * as appSystem from "./app-system"var ThinkingAnalyticsAPI = require("./thinkingdata.mg.wx.min.js");//import sdk from "./oreyunwx.min.js"import { init, loginUserInfo, dataReport, makePayment, shareAppMessage, payConfig, navigateToMiniProgram, getBindPhoneCode, bindPhone, onShareAppMessage, requestSubscribeMessage, triggerSubscribe, createAd } from "gameSDK.bundle.js"var ta;export default { WebChannelLogin(){ //获取微信品台 wx.getSystemInfo({ success (res) { if(res.platform === "ios"){ payConfig().then(res => { let iosPay = "1" if(res.ios_recharge === true && obj.RoleLv > res.ios_level){ iosPay = "1" } else{ iosPay = "0" } GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverIosPayConfig",iosPay); console.log("ios pay " + JSON.stringify(res)) }).catch(error => { console.log("ios pay " + error) }) } } }) if(appEntity.account_id !== ""){ GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverChannelLoginCallBack",appEntity.account_id); var presetProperties = appEntity.ta.getPresetProperties(); var properties = presetProperties.toEventPresetProperties(); GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverPresetProperties",JSON.stringify(properties)); console.log("properties " + JSON.stringify(properties)) return } loginUserInfo().then(res => { console.log("loginUserInfo " + res.uid) appEntity.account_id = res.uid + "" GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverChannelLoginCallBack",appEntity.account_id); var presetProperties = appEntity.ta.getPresetProperties(); var properties = presetProperties.toEventPresetProperties(); GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverPresetProperties",JSON.stringify(properties)); ta.login(appEntity.account_id) }).catch(error => { }) }, WebTrackEvent(eventName,arg){ //console.log(eventName); //console.log(arg); if (arg.length > 0) { var obj = JSON.parse(arg); ta.track(eventName,obj) } else{ ta.track(eventName,{}) } }, WebPayItem(arg){ //console.log("sha1", appSystem.sha1("1646989046234D528C6F23C7D7")) var obj = JSON.parse(arg) if(obj.wx_android === false){ payConfig().then(res => { if(res.ios_recharge === true && obj.RoleLv > res.ios_level){ UpPay(obj) } else{ let objd = { code:1, info:"iOS 用户等级不够" } let jsString = JSON.stringify(objd); SendPayResultMessage(jsString) } console.log("ios pay " + JSON.stringify(res)) }).catch(error => { }) } else{ UpPay(obj) } }, WebSetUserData(arg){ var obj = JSON.parse(arg) ta.userSet(obj); }, WebCallChannelVoidFunWithArg(name,arg){ //GameGlobal.Module.SendMessage("Canvas","ChannelLogout","hahhahah") //appSystem.exportTest1() //appSystem.exportTest2("zhang san") //appSystem.csharp(1,"sss"); //ta.login("ABC_123456"); if(name === "setSuperProperties"){ var obj = JSON.parse(arg) ta.setSuperProperties(obj); } else if(name === "userSet"){ var obj = JSON.parse(arg) ta.userSet(obj); } else if(name === "unityHasInit"){ appEntity.unityHasInit = true } else if(name === "actionRegister"){ ReyunRegister() appSystem.PostSourceRegister() } else if(name === "actionLogin"){ ReyunLogin() } else if(name === "actionPurchase"){ var obj = JSON.parse(arg) ReyunPayment(obj); //appSystem.PostSourcePay(obj.currencyAmount * 100) } else if(name === "showRewardedVideo"){ createAd({ ad_type:"video", task:"" }).then(res => { adHandler("onRewardedVideoAdRewarded","") adHandler("onRewardedVideoAdClosed","") //GameGlobal.Module.SendMessage(appEntity.receivername,"onRewardedVideoAdRewarded",""); //GameGlobal.Module.SendMessage(appEntity.receivername,"onRewardedVideoAdClosed",""); console.log("showRewardedVideo222 " + JSON.stringify(res)) }).catch(error => { console.log("showRewardedVideo11111 " + JSON.stringify(error)) })console.log("VoidFunWithArg " + name + "---" + arg); } else if(name === "SDKInit"){ let tanwandata = { app_version: arg, config_id: "", game_name: "" }; // 初始化小游戏SDK init(tanwandata).then(res => { wx.showToast({ title: "进入游戏成功", }) //拉起订阅 requestSubscribeMessage() //触发订阅 triggerSubscribe("login") }).catch(error => { }) let org = { userType:"TanWan" } ta.userSet(org);console.log("VoidFunWithArg " + name + "---" + arg); } }, WxInit(){ //u8参数初始化 //appSystem.InitU8Arg(); //数数初始化 ShushuInit(); //热云初始化 ///sdk.init(appEntity.reYunAppKey); //登录 //appSystem.channelLogin(); //归因初始化 //SourceInit() }, WebTanWanEvent(eventName,arg){ var obj = JSON.parse(arg) let reportArg = {} if(eventName === "1"){ reportArg.data_type = 1 } else if(eventName === "2"){ reportArg.data_type = 2 } else if(eventName === "3"){ reportArg.data_type = 3 } else if(eventName === "4"){ reportArg.data_type = 4 } reportArg.server_id = 1 reportArg.server_name = "" reportArg.uid = obj.RoleId reportArg.role_id = obj.RoleId reportArg.role_name = "" reportArg.role_level = obj.RoleLv reportArg.role_currency = obj.MoneyNum reportArg.role_create_time = obj.RoleCreateTime reportArg.fight = 1 reportArg.role_sex = 1 reportArg.vip_level = 1 reportArg.role_career = "" dataReport(reportArg).then(res => { }).catch(error => { }) console.log("WebTanWanEvent " + JSON.stringify(reportArg)) }, GetOpenId(openid) { //console.log("account_id " + openid) ta.login(appEntity.account_id); }, ShushuEventTimeStart(eventName){ ta.timeEvent(eventName); }, ShushuJsTrack(eventName,obj){ ta.track(eventName,obj) } }function SendPayResultMessage(re){ console.log("SendPayResult",re) GameGlobal.Module.SendMessage(appEntity.receivername,"PayResult",re);}function ShushuInit(wxcode){ var config = { appId:appEntity.shushuAppId, // 项目 APP ID serverUrl:appEntity.shushuUrl , // 上报地址 enableLog:false, autoTrack: { appShow: true, // 自动采集 ta_mg_show appHide: true // 自动采集 ta_mg_hide } }; // 创建 TA 实例 ta = new ThinkingAnalyticsAPI(config); // 初始化 ta.init(); ta.identify(ta.getDeviceId()); appEntity.ta = ta; //console.log("shushu init") //console.log("getDeviceId",ta.getDeviceId()); // 上报一个简单事件, 事件名为 test_event}function UpPay(obj){ var payArg = {} payArg.uid = "1" payArg.server_id = "1" payArg.server_name = "正式服" payArg.role_id = "1" payArg.role_name = "1" payArg.role_level = 1 payArg.role_currency = 1 payArg.amt = obj.Fee / 100 payArg.game_fee = 1 payArg.product_id = obj.detail payArg.product_name = "游戏充值" payArg.product_desc = "游戏充值" payArg.ext = obj.gameOrderId + ",1174" + "," + obj.rig console.log("payArg" + JSON.stringify(payArg)) makePayment(payArg).then(payres => { wx.getSystemInfo({ success (res) { if(res.platform === "ios"){ } else{ let objd = { code:0, info:"轮询" } let jsString = JSON.stringify(objd); SendPayResultMessage(jsString) } } }) }).catch(error => { })}//热云注册接口function ReyunRegister(){ //sdk.register(appEntity.wxopenId)}function ReyunLogin(){ //sdk.loggedin(appEntity.account_id)}function ReyunPayment(arg){ //js["transactionId"] = transactionId; //js["currencyAmount"] = currencyAmount; //js["currencyType"] = currencyType; //js["paymentType"] = paymentType; //sdk.payment(arg.transactionid,arg.currencyamount,arg.currencytype,arg.paymenttype)}function SourceInit() { let jsobj = wx.getStorageSync("Source") var bb = Object.keys(jsobj) if(bb.length === 0){ //if(true){ //debugger let objs = wx.getLaunchOptionsSync() if ("query" in objs) { let qurayStr = JSON.stringify(objs.query) if (qurayStr.length > 0) { ta.userSet(qurayStr) } } if ("query" in objs) { if ("clue_token" in objs.query) { appEntity.clue_token = objs.query.clue_token; } if ("ad_id" in objs.query) { appEntity.ad_id = objs.query.ad_id; } if ("creative_id" in objs.query) { appEntity.creative_id = objs.query.creative_id; } if ("req_id" in objs.query){ appEntity.req_id = objs.query.req_id; } if ("advertiser_id" in objs.query) { appEntity.advertiser_id = objs.query.advertiser_id; } if ("project_id" in objs.query) { appEntity.advertiser_id = objs.query.project_id; } if ("promotion_id" in objs.query) { appEntity.advertiser_id = objs.query.promotion_id; } if ("mid1" in objs.query) { appEntity.mid1 = objs.query.mid1; } if ("mid2" in objs.query) { appEntity.mid2 = objs.query.mid2; } if ("mid3" in objs.query) { appEntity.mid3 = objs.query.mid3; } if ("mid4" in objs.query) { appEntity.mid4 = objs.query.mid4; } if ("mid5" in objs.query) { appEntity.mid5 = objs.query.mid5; } } let obj = { ad_id:appEntity.ad_id, creative_id:appEntity.creative_id, advertiser_id:appEntity.advertiser_id, clue_token:appEntity.clue_token, }; let str = JSON.stringify(obj); //console.log(str); wx.setStorageSync("Source",str) appEntity.firstOpen = true; } else{ let sorObj = JSON.parse(jsobj); appEntity.ad_id = sorObj.ad_id; appEntity.creative_id = sorObj.creative_id; appEntity.advertiser_id = sorObj.advertiser_id; appEntity.clue_token = sorObj.clue_token; } } function adHandler(funName,arg){ let obj = { "FunName":funName, "Arg":arg } let tarStr = JSON.stringify(obj) console.log("tarStr " + tarStr) GameGlobal.Module.SendMessage(appEntity.receivername,"AdHandler",tarStr); }
在index 中将 apps 方法注册到全局表中
import apps from "./apps";const WXWASMSDK = { /* 初始化 */ WXInitializeSDK() { moduleHelper.init(); moduleHelper.send("Inited", 200); }, ...storage, ...userInfo, ...share, ...ad, ...canvasHelper, ...fs, ...openData, ...util, ...cloud, ...audio, ...texture, ...video, ...logger, ...shortAudio, ...gameClub, canvasContext, ...sdk, ...camera, ...recorder, ...uploadFile, ...gameRecorder, ...apps, //加的这个};
SDK 初始化在 Game.js 中
GameGlobal.WXWASMSDK.WxInit();
实为apps 的调用方法
新建 app-system
import {appEntity} from "./app-entity";import {appSanboxCfg} from "./appSanboxCfg";import { CryptoJS } from "./CryptoJS.js";export function exportTest1() { }export function exportTest2(name) { }export function csharp(id,errMsg){ }export function js(){}export function u8Post(url, postData, doSuccess, doFail){ var base = appEntity.u8ServerUrl wx.request({ //项目的真正接口,通过字符串拼接方式实现 url: base + url, // 这个header根据你的实际改! header:{ "X-GameId":appEntity.u8GameId, "X-ChannelId":appEntity.u8ChannelId, "X-PackageId":appEntity.u8PackageId, "Content-Type": "application/json", "cookie": appEntity.u8HttpToken, "Request-Origin": "app" }, data: postData, method: "POST", success: function (res) { //参数值为res.data,直接将返回的数据传入 //if (res.data.result.token) { // 如果有token保存下来,下次请求带着token访问 // appEntity.u8HttpToken = res.data.result.token; // console.log("token--> ", appEntity.u8HttpToken) //} doSuccess(res.data); }, fail: function () { doFail(); }, })}export function u8GetData(url, getData, doSuccess, doFail) { wx.request({ url: url, header: { "Content-Type": "application/json", "X-Access-Token": appEntity.u8HttpToken, "Request-Origin": "app" }, method: "GET", data: getData, success: function (res) { doSuccess(res.data); }, fail: function () { doFail(); }, })}export function getSignStringFromObj(obj){ let arrIndex = 0; let arr = []; for (let key in obj) { if (obj.hasOwnProperty(key)) { arr[arrIndex] = { paramKey:key, paramVal:obj[key], } arrIndex = arrIndex + 1 } } arr.sort(compare); let targeStr = ""; for(var i = 0; i < arr.length; i++){ if(targeStr !== ""){ targeStr = targeStr + "&" } targeStr = targeStr + arr[i].paramKey + "=" + arr[i].paramVal; } obj.timestamp = Date.now(); obj.nonce = 3652; targeStr = targeStr + "&" + "timestamp="+ obj.timestamp +"&nonce=" + obj.nonce //console.log("test target " + targeStr); return targeStr;}export function channelLogin(){ //u8 完成登录就不回去登录 if(appEntity.account_id !== ""){ GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverChannelLoginCallBack",appEntity.account_id); var presetProperties = appEntity.ta.getPresetProperties(); var properties = presetProperties.toEventPresetProperties(); GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverPresetProperties",JSON.stringify(properties)); console.log("properties " + JSON.stringify(properties)) return } wx.login({ success: function(res) { //console.log(res.code);//这里的返回值就有Code信息 u8Login(res.code); //debugger; }, fail: function(res) { let loginArg = { result:false, fail_reason:"wx fail", } GameGlobal.WXWASMSDK.ShushuJsTrack("U8_init",loginArg); }, complete: function(res) {}, })}function u8Login(code){ let url = "usercenter/wx1/login"; let data = { wx_code : code, } let signCode = getSignStringFromObj(data); var hash_result = CryptoJS.HmacSHA256(signCode, appEntity.u8Sign).toString(); data.sign = hash_result; u8Post(url,data, function(succ){ if(succ.code === 200){ appEntity.account_id = succ.data.account_id; appEntity.wxopenId = succ.data.openid; //console.log("wxopenId " + succ.data.openid) //debugger appEntity.wxtoken = succ.data.token; //热云初始化,数数login GameGlobal.WXWASMSDK.GetOpenId(appEntity.wxopenId); //这个要微信的数据 PostSourceActive() GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverChannelLoginCallBack",appEntity.account_id); var presetProperties = appEntity.ta.getPresetProperties(); //生成事件预置属性 var properties = presetProperties.toEventPresetProperties(); GameGlobal.Module.SendMessage(appEntity.receivername,"ReceiverPresetProperties",JSON.stringify(properties)); let loginArg = { result:true, fail_reason:"u8 server ok", } GameGlobal.WXWASMSDK.ShushuJsTrack("U8_init",loginArg); let reArg = { login_type:"weixin", login_id:appEntity.account_id, result:true, fail_reason:"ok" } GameGlobal.WXWASMSDK.ShushuJsTrack("login_result",reArg); } else{ let loginArg = { result:false, fail_reason:succ.message, } GameGlobal.WXWASMSDK.ShushuJsTrack("U8_init",loginArg); } }, function(){ let loginArg = { result:false, fail_reason:"u8 server error", } GameGlobal.WXWASMSDK.ShushuJsTrack("U8_init",loginArg); })}function compare(obj1, obj2) { let val1 = obj1.paramKey; let val2 = obj2.paramKey; if (val1 < val2) { return -1; } else if (val1 > val2) { return 1; } else { return 0; }}//用户点击了支付export function wxPay(csobj){ wx.login({ success: function(res) { upWxPay(csobj,res.code) }, fail: function(res) { let objd = { code:1, info:"获取微信code失败" } let jsString = JSON.stringify(objd); SendPayResultMessage(jsString) }, complete: function(res) { }, })}function getSignature(arg,succfunc) { let data = { account_id:appEntity.account_id, nickname:arg.nickName, gender:arg.gender, language:arg.language, city:arg.city, province:arg.province, country:arg.country, avatar_url:arg.avatarUrl, } let signCode = getSignStringFromObj(data); var hash_result = CryptoJS.HmacSHA256(signCode, appEntity.u8Sign).toString(); data.sign = hash_result; //debugger u8Post("/usercenter/wx1/min/signature",data, function(params) { appEntity.signature = params.data.signature; succfunc(params) //debugger }, function(params) { })}function upWxPay(csobj,wxcode) { let arg = { mode:"game", env:appEntity.env, offerId:appEntity.offerId, currencyType:"CNY", platform:"android", buyQuantity:csobj.Fee / 10, zoneId:"1", success:function(res){ //console.log("paysucc " + JSON.stringify(res)) webAndroidMoneyHasGone(csobj,wxcode) }, fail:function(res){ //console.log(res) let objd = { code:1, info:res } let jsString = JSON.stringify(objd); SendPayResultMessage(jsString) webAndroidMoneyHasGone(csobj,wxcode) console.log("payfail " + JSON.stringify(res)) }, complete:function(){ //通知服务器去微信服扣货 }, }; //拉起微信支付 wx.requestMidasPayment(arg); //webAndroidMoneyHasGone(csobj,wxcode) //console.log("appEntity.offerId offerIdofferId " + appEntity.offerId)}function webAndroidMoneyHasGone(objCharp,code){ let postData = {}; postData.env = appEntity.env postData.openid = appEntity.wxopenId; //postData.appid = appEntity.wxAppId; postData.offer_id = appEntity.offerId; postData.zone_id = 1 postData.access_token = appEntity.weixinServerToken; postData.game_orderid = objCharp.gameOrderId postData.js_code = code postData.accountid = appEntity.account_id //debugger var base = appEntity.webAndroidPayUrl; //console.log("base" + base) wx.request({ //项目的真正接口,通过字符串拼接方式实现 url: base, // 这个header根据你的实际改! header: { "Content-Type": "application/json", "Request-Origin": "app" }, data: postData, method: "POST", success: function (res) { //debugger let objd = { code:0, info:"支付成功" } let jsString = JSON.stringify(objd); SendPayResultMessage(jsString) }, fail: function () { //debugger //doFail(); let objd = { code:1, info:"从微信扣款失败" } let jsString = JSON.stringify(objd); SendPayResultMessage(jsString) }, })}function encodeUTF8(s) { var i, r = [], c, x; for (i = 0; i < s.length; i++) if ((c = s.charCodeAt(i)) < 0x80) r.push(c); else if (c < 0x800) r.push(0xC0 + (c >> 6 & 0x1F), 0x80 + (c & 0x3F)); else { if ((x = c ^ 0xD800) >> 10 == 0) //对四字节UTF-16转换为Unicode c = (x << 10) + (s.charCodeAt(++i) ^ 0xDC00) + 0x10000, r.push(0xF0 + (c >> 18 & 0x7), 0x80 + (c >> 12 & 0x3F)); else r.push(0xE0 + (c >> 12 & 0xF)); r.push(0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F)); }; return r;}; // 字符串加密成 hex 字符串export function sha1(s) { var data = new Uint8Array(encodeUTF8(s)) var i, j, t; var l = ((data.length + 8) >>> 6 << 4) + 16, s = new Uint8Array(l << 2); s.set(new Uint8Array(data.buffer)), s = new Uint32Array(s.buffer); for (t = new DataView(s.buffer), i = 0; i < l; i++)s[i] = t.getUint32(i << 2); s[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8); s[l - 1] = data.length << 3; var w = [], f = [ function () { return m[1] & m[2] | ~m[1] & m[3]; }, function () { return m[1] ^ m[2] ^ m[3]; }, function () { return m[1] & m[2] | m[1] & m[3] | m[2] & m[3]; }, function () { return m[1] ^ m[2] ^ m[3]; } ], rol = function (n, c) { return n << c | n >>> (32 - c); }, k = [1518500249, 1859775393, -1894007588, -899497514], m = [1732584193, -271733879, null, null, -1009589776]; m[2] = ~m[0], m[3] = ~m[1]; for (i = 0; i < s.length; i += 16) { var o = m.slice(0); for (j = 0; j < 80; j++) w[j] = j < 16 ? s[i + j] : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1), t = rol(m[0], 5) + f[j / 20 | 0]() + m[4] + w[j] + k[j / 20 | 0] | 0, m[1] = rol(m[1], 30), m.pop(), m.unshift(t); for (j = 0; j < 5; j++)m[j] = m[j] + o[j] | 0; }; t = new DataView(new Uint32Array(m).buffer); for (var i = 0; i < 5; i++)m[i] = t.getUint32(i << 2); var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) { return (e < 16 ? "0" : "") + e.toString(16); }).join(""); return hex;};function PostSourceActive() { if (appEntity.firstOpen) { let jsondata = { clue_token:appEntity.clue_token, open_id:appEntity.wxopenId, event_type:"0" } PostSourceHttp(jsondata) }}export function PostSourceRegister() { let jsondata = { clue_token:appEntity.clue_token, open_id:appEntity.wxopenId, event_type:"1" } PostSourceHttp(jsondata)}export function PostSourcePay(amount) { let jsondata = { clue_token:appEntity.clue_token, open_id:appEntity.wxopenId, event_type:"2", props:{ pay_amount:amount } } PostSourceHttp(jsondata)}function PostSourceHttp(jsondata){ let time = Date.now(); let nonce = Math.round(Math.random()*10); let strList = [appEntity.sourcetoken, time, nonce]; strList.sort(); let buffer = ""; strList.forEach(str => { buffer += str; }) let sign = sha1(buffer) //debugger let targeturl = appEntity.sourceUrl + "?timestamp=" + time + "&nonce="+ nonce +"&signature=" + sign //console.log("url " + targeturl) wx.request({ url:targeturl, header: { "Content-Type": "application/json", "Request-Origin": "app" }, data: jsondata, method: "POST", success: function (res) { //console.log("zhangsan " + JSON.stringify(res.data)) }, fail:function(){ }, })}export function WebiOSPay(obj){ let amount = obj.Fee; let accid = appEntity.account_id; let url = appEntity.webiOSNotPayUrl; let extension = obj.extension let server_id = 1 let game = obj.body let goods = "方块大作战充值" let targetStr = `../index/index?notify_type=createorder&amount=${amount}&account_id=${accid}¬ify_url=${url}&extension=${extension}&server_id=${server_id}&game=${game}&goods=${goods}` //console.log(targetStr + "targetStr") wx.openCustomerServiceConversation({ showMessageCard: true, sessionFrom: "game", sendMessagePath:targetStr, sendMessageTitle:"我要充值", sendMessageImg: "https://c-ssl.duitang.com/uploads/blog/202102/12/20210212163554_83b7a.jpg", success() { //console.log("调起成功"); }, fail() { //console.log("调起失败"); }});}export function SendPayResultMessage(re){ //console.log("zhangsan",re) GameGlobal.Module.SendMessage(appEntity.receivername,"PayResult",re);}export function InitU8Arg() { if (appSanboxCfg.sanbox) { appEntity.u8appid = appEntity.u8 appEntity.u8GameId = appEntity.u8GameIdTest; appEntity.u8ChannelId = appEntity.u8ChannelIdTest; appEntity.u8PackageId = appEntity.u8PackageIdTest; appEntity.u8Sign = appEntity.u8SignTest; appEntity.u8ServerUrl = appEntity.u8ServerUrlTest; appEntity.env = appEntity.envTest }}
还有个app-entity 存放变量的
export var appEntity = { //与U8交互的口令 暂时没有用 u8HttpToken : null, //测试参数 u8appidTest:, u8GameIdTest : "", u8ChannelIdTest : "", u8PackageIdTest : "", u8SignTest:"", u8ServerUrlTest:"", //正式参数 u8appid:, u8GameId : "", u8ChannelId : "", u8PackageId : "", u8Sign:"", u8ServerUrl:"", //登录获取的账户id account_id:"", //微信的union_id union_id:"", //登录获取的微信id wxopenId:"", //后端与微信后端交互口令 wxtoken:"", //unity 是否初始胡完成 unityHasInit:false, //webAndroid 支付url webAndroidPayUrl:"", //微信后台虚拟货币id //offerId:"", offerId:"", //微信的appid wxAppId:"", env:0, envTest:1, //热云appkey reYunAppKey:"", // receivername:"Global", //游戏服和微信服交互的token weixinServerToken:"", //归因 ad_id:"", creative_id:"", advertiser_id:"", clue_token:"", req_id:"", project_id:"", promotion_id:"", mid1:"", mid2:"", mid3:"", mid4:"", mid5:"", firstOpen:false, // 归因服url sourceUrl:"", sourcetoken:"", webiOSNotPayUrl:"", //数数 shushuAppId:"", shushuUrl:"", ta:"",}
快讯:Unity 转小游戏
环球热讯:基于开源IM即时通讯框架MobileIMSDK:RainbowChat v8.4版已发布
世界快播:Linux输入设备驱动
微资讯!壮观!马斯克星链卫星驶过西班牙夜空:宛若空中列车
【世界聚看点】小学生满分作文跑题老师含泪打5分:把“悔”看成“梅”
环球热资讯!特斯拉京东旗舰店开业:269元的U盘上架
首发16.2元:《仙剑奇侠传7》DLC《人间如梦》正式上线
ChatGPT版必应发飙!怒斥人类:放尊重些
天天快播:IM通讯协议专题学习(九):手把手教你如何在iOS上从零使用Protobuf
ChatGPT注册试用过程分享
全球观察:响应式圣经:10W字,实现Spring响应式编程自由
全球短讯!Unicorn 初探
7万起售 五菱缤果内饰官图发布:同级无敌手
世界上最轻VR头显面世:仅重127克 5K分辨率
环球新消息丨苹果汽车奇瑞造?“果链一哥”立讯与奇瑞签署合作 联手造车
当前动态:法拉第未来:预计FF 91将于4月底交付 但有个前提
不用第三方插件了:微软计划为Edge加入鼠标手势功能
qq空间主人寄语怎么删除?qq空间主人寄语大集合
开学的歌曲有哪些?开学的趣事作文模板
熟悉的人是什么意思?关于我最熟悉的人作文合集
皮脂腺分泌旺盛是什么原因?皮脂腺分泌旺盛怎么解决?
代表月亮消灭你是什么意思?代表月亮消灭你是谁的经典台词?
天天亮点!【AI】PTP时钟同步在智能驾驶系统里的重要性
天天微资讯!去掉Element 中el-input type=number时尾部上下箭头、禁用鼠标滚动
世界热点评!数组中找出只出现一次的两个数字
剑灵活力值在哪里显示?剑灵活力值怎么恢复?
ie图标不见了是怎么回事?ie图标不见了怎么恢复?
闪存和硬盘哪个重要?闪存和硬盘有什么区别?
料理机是干什么用的?料理机品牌十大排名
光纤路由器怎么设置?光纤路由器和宽带路由器一样吗?
速看:口味地道 丰富配料!渣渣灰南昌拌粉好价:4.9元/盒
全球新资讯:129元!小米2C1A三口GaN充电器上架:最高67W 兼容65W PD
天天信息:3秒俱乐部成员!极氪X官图公布:2750mm轴距百变魔方空间
63岁老人喝隔夜牛肉汤:结果住进ICU
黑龙江上空现不明飞行物速度极快 网友脑洞大开:LED风筝?
今日报丨程序员健康最佳作息表,建议收藏!!
必知必会的设计原则——合成复用原则
腾讯云企业网盘正式入驻数字工具箱
每日关注!软件开发入门教程网之Bootstrap4 信息提示框
【天天报资讯】适用于您企业的本地密码管理器丨Passwork产品介绍
瞧不起ChatGPT?苹果联合创始人:永远取代不了人类
【天天播资讯】热狗车三元催化被盗
宁德时代赴美建厂 官方回应:属实!福特出地出厂房
天天微头条丨丰田考斯特绝佳替代品 红旗全新中巴亮相:3.0T能坐23人
世界视讯!情人节前夕 东极岛海誓山盟石碑碎了 网友:承受太多誓言
百事通!RTX 4060桌面显卡被砍得面目全非:说好的万人迷呢?
匠人精神也不行!日本制造加速下滑:破产企业数量激增 汽车、电子业空心化
当前动态:情人节的垃圾桶成了“致富秘笈”?能捡到鲜花蛋糕等:网友戏称拆“爱情盲盒”
拒绝刹车失灵等污名化!美国还特斯拉清白:2年前车祸是司机醉酒超速
今日热议:微信情人节限定状态上线!撒狗粮/吃狗粮专属状态你选谁?
ChatGPT:Are You Ok是卢伟冰唱的 雷军不是专业歌手
世界新消息丨读Java实战(第二版)笔记09_函数式的思考
【当前独家】今天情人节 微信可以发520元红包 律师提醒:分手可能要不回
当前聚焦:曝马斯克有意45亿镑收购曼联:去年曾现身世界杯看球
世界视点!最高补贴5000元!为什么中国规定男性一生只能捐精一次?
头条:微软Win10今日停止支持IE11:强制跳转Edge 网友担心银行拖后腿
报道:2022年游戏十强年度榜公布:《王者荣耀》《原神》等上榜
每日视点!草莓的“种子”为什么裸露在外呢?大有讲究
13代i9+RTX 4070加持!ROG幻16经典版 2023图赏
当前热门:1.html篇之《html基础入门》
天天微资讯!leetcode:求两数之和-easy
世界讯息:maven 工程pom依赖优化及常用命令
全球百事通!世界超6成新能源汽车来自中国 比亚迪2022年累计出口55916辆
视讯!29.9元充值100元话费?套路满满 18家经营者被约谈
腾讯:我们发现了ChatGPT的又一个短板
【天天新要闻】判断二叉树是否为平衡二叉树
全球播报:《分布式技术原理与算法解析》学习笔记Day10
环球今日报丨微信多开&防撤回工具再也不用担心好友撤回消息了
天天讯息:打开MASA Blazor的正确姿势4.2:Flex弹性布局
14nm+++再也不见 Intel告别最长寿的CPU工艺:9年不落伍
【全球快播报】利用反射和代理简单模拟mybatis实现简单的CRUD
世界微动态丨Docker参数命令大全详解
男子驾车路遇“雪狼” 回头瞬间笑喷:原是只哈士奇
【热闻】刘作虎宣布闭关打磨细节:OPPO Find X6就快来了
当前速读:苹果联合创始人称ChatGPT不懂人性:可能会犯下可怕错误
《流浪地球2》里的“天梯”真的能建成吗?
每日短讯:开学小测总结(下)
【报资讯】【DFS】飞行员兄弟
今日热闻!03.Python Dash网页开发:多页面网站制作
【环球报资讯】二叉树的深度之DFS、BFS
当前头条:猛男最爱!Xbox手柄新配色“浪漫粉”今晚发售 网友惊了
当前快播:唯一16GB显存!宏碁Intel Arc A770旗舰显卡降价:2380元最便宜
直降700元 小牛G2/G2s部分车型促销:理论续航60-90公里
环球速讯:曾靠6字赚苹果上千万的汉王 怎么就搭上ChatGPT的风口
环球看热讯:你喝奶 选哪个品牌放心?蒙牛回应男子买酸奶打开全是清水
RTX 30别买了 高性价比RTX 40游戏本杀到:价格屠夫还是这两家
全球观速讯丨40S精梳棉 裸感体验:老牌宜而爽平角裤39元4条发车
环球讯息:短信不死
全球关注:检测到外星生命“存在证据”!“三体人”要来了吗?
天天报道:吉利赚了10个沃尔沃
记录--数组去重的五种方法
每日看点!D. Moscow Gorillas
环球热消息:Microsoft Azure 教程_编程入门自学教程_菜鸟教程-免费教程分享
环球百事通!文盘Rust -- 领域交互模式如何实现
打开MASA Blazor的正确姿势1:目录&MASA Blazor是???
全球最新:多家游戏公司招聘客服实为找托:引导玩家氪金
即时看!长城大力布局新能源 哈弗如歌、枭龙曝光:外观个性均可上绿牌
明天是情人节!全国多地现巨型玫瑰
世界看热讯:谁说鱼只有7秒记忆?研究首次证明鱼能认出自己的脸
今日热闻!马斯克“黑子”自费400万元 把特斯拉FSD负面广告送上美国超级碗