东风启辰小程序端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
pirms 5 gadiem
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. //app.js
  2. App({
  3. onLaunch: function (options) {
  4. this.globalData.sceneSource = options.scene;
  5. if (options.referrerInfo && options.referrerInfo.extraData && options.referrerInfo.extraData.source) {
  6. this.globalData.sceneSource = options.referrerInfo.extraData.source;
  7. } else if (options.query && options.query.scene) {
  8. var scene = decodeURIComponent(options.query.scene);
  9. var source = scene.split("&");
  10. for (let i = 0; i < source.length; i++) {
  11. var split = source[i].split("=");
  12. source[i] = [split[0], split[1]];
  13. if (split[0] == "source") {
  14. this.globalData.sceneSource = split[1];
  15. }
  16. }
  17. }
  18. // 展示本地存储能力
  19. var openid = wx.getStorageSync('openid') || "";
  20. if (!openid) {
  21. // 登录
  22. this.wxLogin();
  23. } else {
  24. this.globalData.openid = openid;
  25. this.addAppEnter();
  26. this.getBuyState();
  27. }
  28. var entered = wx.getStorageSync('entered');
  29. if (entered) {
  30. this.globalData.entered = entered;
  31. }
  32. var userMobile = wx.getStorageSync('userMobile');
  33. if (userMobile){
  34. this.globalData.userMobile = userMobile;
  35. }
  36. var parentOpenid = wx.getStorageSync('parentOpenid');
  37. if (parentOpenid) {
  38. this.globalData.parentOpenid = parentOpenid;
  39. }
  40. var certificationInfo = wx.getStorageSync('certificationInfo');
  41. if (certificationInfo) {
  42. this.globalData.certificationInfo = certificationInfo;
  43. }
  44. var userInfoData = wx.getStorageSync("userInfoData");
  45. if (userInfoData){
  46. this.globalData.userInfoData = {};
  47. this.globalData.userInfoData.avatarUrl = userInfoData.avatarUrl;
  48. this.globalData.userInfoData.nickName = userInfoData.nickName;
  49. this.globalData.userInfoData.userLevel = userInfoData.userLevel;
  50. }else{
  51. if (openid){
  52. this.getUserInfo();
  53. }
  54. }
  55. var userPhoneType = wx.getStorageSync('userPhoneType');
  56. if (userPhoneType) {
  57. this.globalData.userPhoneType = userPhoneType;
  58. } else {
  59. this.getPhoneType();
  60. }
  61. },
  62. getPhoneType() {//获取手机类型
  63. wx.getSystemInfo({
  64. success: res => {
  65. wx.setStorageSync("userPhoneType", res.platform);
  66. this.globalData.userPhoneType = res.platform;
  67. }
  68. })
  69. },
  70. wxLogin() {
  71. wx.login({
  72. success: res => {
  73. if (res.code) {
  74. this.getOpenid(res.code);
  75. } else {
  76. console.log('登录失败!' + res.errMsg)
  77. }
  78. }
  79. })
  80. },
  81. globalData: {
  82. // urlRoot: "https://dongfengqichen.jiyou-tech.com/",//测试接口根目录
  83. urlRoot: "https://xing.venucia.com/api/",//接口根目录
  84. // urlStatic: "https://www.jiyou-tech.com/2020/496_qichen/static",//测试静态资源根目录
  85. urlStatic: "https://xingb.venucia.com/resource",//静态资源根目录
  86. openid: "",//OPENID
  87. parentOpenid:"",//推荐人的openid
  88. session_key: "",//session_key
  89. openidSuccessFuc: null,//方法回调
  90. buyStateSuccessFuc:null,
  91. nowPage:'0',//当前tabBar
  92. isRegister:false,//是否已注册
  93. userMobile:null,//用户手机号
  94. isFirstLogin: true,//是否为第一次登录
  95. isFirstLucky: true,//是否为第一次进入幸运星抓手
  96. indexData:{},//首页数据
  97. myCenterData:null,//个人中心数据
  98. userInfoData:{
  99. "avatarUrl":"",
  100. "nickName":""
  101. },
  102. certificationState:0,//1车主,2合伙人,3同事
  103. mobileData:null,
  104. userPhoneType:null,
  105. kvurl:null,
  106. kvurlH:0,
  107. certificationInfo:false,
  108. getBuyState:null,
  109. entered:false,
  110. authenticationStatus:null,
  111. skipType:null,
  112. sceneSource:'',
  113. addPageEnterState:{
  114. index:false,
  115. luckyStar:false,
  116. star:false,
  117. myCenter:false,
  118. guessPrize:false,
  119. everyday:false
  120. },
  121. getSecondGuessInfo:{//第二轮价格竞猜信息
  122. secondData:null,
  123. firstData:null
  124. },
  125. getSecondGuessInfoV2:null,//第二轮价格竞猜结果
  126. phonebolb:false,
  127. },
  128. // 获取openId
  129. getOpenid: function (code) {
  130. wx.showLoading({
  131. title: '加载中',
  132. mask: true,
  133. })
  134. this.wxRequest(this.globalData.urlRoot + "wxInfo/getOpenid", { code: code }, res => {
  135. wx.hideLoading();
  136. if (res.code == 200) {
  137. wx.setStorageSync("openid", res.data.openid);
  138. wx.setStorageSync("session_key", res.data.session_key);
  139. this.globalData.openid = res.data.openid;
  140. this.globalData.session_key = res.data.session_key;
  141. if (this.globalData.openidSuccessFuc) {
  142. this.globalData.openidSuccessFuc();
  143. }
  144. if(this.globalData.mobileData){
  145. this.getMobile2(this.globalData.mobileData.encryptedData, this.globalData.mobileData.iv, this.globalData.mobileData.callback, this.globalData.mobileData.thisArg);
  146. }
  147. var userInfoData = wx.getStorageSync("userInfoData");
  148. if (!userInfoData) {
  149. this.getUserInfo();
  150. }
  151. this.addAppEnter();
  152. this.getBuyState();
  153. } else {
  154. wx.showToast({
  155. title: res.msg,
  156. icon: "none"
  157. })
  158. }
  159. }, this);
  160. },
  161. /**
  162. * wx.request
  163. */
  164. wxRequest: function (url, params, callback, thisArg, methods, openid) {
  165. let that = this;
  166. var httpUrl = url;
  167. var str = "";
  168. var count = 0;
  169. for (let key in params) {
  170. if (count) {
  171. str += "&" + key + "=" + params[key];
  172. } else {
  173. str += key + "=" + params[key];
  174. }
  175. count++;
  176. }
  177. if (str) {
  178. httpUrl += "?" + str;
  179. }
  180. if (!methods) {
  181. methods = "GET";
  182. }
  183. if (methods == "POST") {
  184. wx.request({
  185. url: url,
  186. data: params,
  187. method: methods,
  188. header: {
  189. "content-type": "application/x-www-form-urlencoded",
  190. "VERSION": '100',
  191. "OPENID": this.globalData.openid
  192. },
  193. success: function (re) {
  194. // if (re.data.code == -1002) {
  195. // wx.removeStorageSync('openid');
  196. // that.wxLogin();
  197. // // that.wxRequest(url, params, callback, thisArg, methods, openid);
  198. // }
  199. if (callback && thisArg) {
  200. callback.call(thisArg, re.data);
  201. }
  202. },
  203. fail: function (re) {
  204. wx.hideLoading();
  205. }
  206. })
  207. } else {
  208. wx.request({
  209. url: httpUrl,
  210. method: methods,
  211. header: {
  212. "OPENID": this.globalData.openid,
  213. "VERSION": '100'
  214. },
  215. success: function (re) {
  216. if (re.data.code == -1002) {
  217. wx.removeStorageSync('openid');
  218. // that.wxLogin();
  219. // that.wxRequest(url, params, callback, thisArg, methods, openid);
  220. }
  221. if (callback && thisArg) {
  222. callback.call(thisArg, re.data);
  223. }
  224. },
  225. fail: function (res) {
  226. wx.hideLoading();
  227. }
  228. })
  229. }
  230. },
  231. submitUserMsg: function (avatarUrl, nickName) {//提交用户信息
  232. this.wxRequest(this.globalData.urlRoot + "userInfo/updateUserInfo", { avatarUrl: avatarUrl, nickName: nickName }, res => {
  233. if (res.code == 200) {
  234. this.globalData.userInfoData = {};
  235. this.globalData.userInfoData.avatarUrl = avatarUrl;
  236. this.globalData.userInfoData.nickName = nickName;
  237. wx.setStorageSync('userInfoData', {
  238. avatarUrl: avatarUrl,
  239. nickName: nickName,
  240. userLevel:1
  241. })
  242. }
  243. }, this, "POST")
  244. },
  245. codeVerify: function (card) {//身份证号码验证
  246. let rule = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)/;
  247. return rule.test(card);
  248. },
  249. mobileVerify: function (mobile) {//手机号验证
  250. let rule = /^1\d{10}$/;
  251. return rule.test(mobile);
  252. },
  253. callMobile: function (e) {//拨打电话
  254. wx.makePhoneCall({
  255. phoneNumber: e //仅为示例,并非真实的电话号码
  256. })
  257. },
  258. sharePack: function () {//分享
  259. return {
  260. title: '发现宝藏小程序!玩游戏赢好礼,来一起探寻更多惊喜吧!',
  261. imageUrl: this.globalData.urlStatic+"/newImages6/25.png",
  262. path: "/pages/index/index"
  263. }
  264. },
  265. addformId: function (e) {//添加formid
  266. this.wxRequest(this.globalData.urlRoot + "/msg/addFormId", { formid: e }, res => {
  267. console.log(res.msg);
  268. }, this, "POST");
  269. },
  270. getMobile: function (encryptedData, iv, callback, thisArg) {//检查登录态是否过期
  271. wx.checkSession({
  272. success: res => {
  273. this.getMobile2(encryptedData,iv,callback,thisArg);
  274. },
  275. fail: res => {
  276. this.globalData.mobileData = {};
  277. this.globalData.mobileData.encryptedData = encryptedData;
  278. this.globalData.mobileData.iv = iv;
  279. this.globalData.mobileData.callback = callback;
  280. this.globalData.mobileData.thisArg = thisArg;
  281. this.wxLogin();
  282. }
  283. })
  284. },
  285. getMobile2: function (encryptedData, iv, callback, thisArg) {//和后台置换手机号
  286. this.globalData.mobileData = null;
  287. this.wxRequest(this.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: encryptedData, iv: iv }, res => {
  288. if (res.code == 200) {
  289. if (res.data && res.data.decodeData) {
  290. wx.setStorageSync('userMobile', res.data.decodeData.phoneNumber);
  291. this.globalData.userMobile = res.data.decodeData.phoneNumber;
  292. }
  293. }
  294. if (callback && thisArg) {
  295. callback.call(thisArg, res);
  296. }
  297. }, this, "POST");
  298. },
  299. getUserInfo: function () {//获取个人信息
  300. this.wxRequest(this.globalData.urlRoot +"userInfo/getUserInfo",{},res=>{
  301. if(res.code==200){
  302. if (res.data && res.data.avatarUrl) {
  303. this.globalData.userInfoData = {};
  304. this.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  305. this.globalData.userInfoData.nickName = res.data.nickName;
  306. this.globalData.userInfoData.userLevel = res.data.userLevel;
  307. wx.setStorageSync('userInfoData', {
  308. avatarUrl: res.data.avatarUrl,
  309. nickName: res.data.nickName,
  310. userLevel: res.data.userLevel
  311. })
  312. }
  313. }
  314. },this)
  315. },
  316. getBuyState: function () {//查询是否已下订
  317. this.wxRequest(this.globalData.urlRoot + "wxPay/getBuyState", {source:2}, res => {
  318. if (res.code == 200) {
  319. if (res.data) {
  320. res.data.cdate = res.data.cdate ? res.data.cdate : "";
  321. this.globalData.getBuyState = res.data;
  322. if (this.globalData.buyStateSuccessFuc){
  323. this.globalData.buyStateSuccessFuc();
  324. }
  325. }
  326. }
  327. }, this);
  328. },
  329. addAppEnter: function () {//小程序整体pv统计
  330. this.wxRequest(this.globalData.urlRoot + "statistics/addAppEnter", { scene:this.globalData.sceneSource}, res => {
  331. }, this,"POST");
  332. },
  333. addPageEnter: function (e) {//小程序页面pv统计
  334. this.wxRequest(this.globalData.urlRoot + "statistics/addPageEnter", { scene: this.globalData.sceneSource, statisticsType:e }, res => {
  335. }, this, "POST");
  336. }
  337. })