东风启辰小程序端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
5 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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. },
  127. // 获取openId
  128. getOpenid: function (code) {
  129. wx.showLoading({
  130. title: '加载中',
  131. mask: true,
  132. })
  133. this.wxRequest(this.globalData.urlRoot + "wxInfo/getOpenid", { code: code }, res => {
  134. wx.hideLoading();
  135. if (res.code == 200) {
  136. wx.setStorageSync("openid", res.data.openid);
  137. wx.setStorageSync("session_key", res.data.session_key);
  138. this.globalData.openid = res.data.openid;
  139. this.globalData.session_key = res.data.session_key;
  140. if (this.globalData.openidSuccessFuc) {
  141. this.globalData.openidSuccessFuc();
  142. }
  143. if(this.globalData.mobileData){
  144. this.getMobile2(this.globalData.mobileData.encryptedData, this.globalData.mobileData.iv, this.globalData.mobileData.callback, this.globalData.mobileData.thisArg);
  145. }
  146. var userInfoData = wx.getStorageSync("userInfoData");
  147. if (!userInfoData) {
  148. this.getUserInfo();
  149. }
  150. this.addAppEnter();
  151. this.getBuyState();
  152. } else {
  153. wx.showToast({
  154. title: res.msg,
  155. icon: "none"
  156. })
  157. }
  158. }, this);
  159. },
  160. /**
  161. * wx.request
  162. */
  163. wxRequest: function (url, params, callback, thisArg, methods, openid) {
  164. let that = this;
  165. var httpUrl = url;
  166. var str = "";
  167. var count = 0;
  168. for (let key in params) {
  169. if (count) {
  170. str += "&" + key + "=" + params[key];
  171. } else {
  172. str += key + "=" + params[key];
  173. }
  174. count++;
  175. }
  176. if (str) {
  177. httpUrl += "?" + str;
  178. }
  179. if (!methods) {
  180. methods = "GET";
  181. }
  182. if (methods == "POST") {
  183. wx.request({
  184. url: url,
  185. data: params,
  186. method: methods,
  187. header: {
  188. "content-type": "application/x-www-form-urlencoded",
  189. "VERSION": '100',
  190. "OPENID": this.globalData.openid
  191. },
  192. success: function (re) {
  193. // if (re.data.code == -1002) {
  194. // wx.removeStorageSync('openid');
  195. // that.wxLogin();
  196. // // that.wxRequest(url, params, callback, thisArg, methods, openid);
  197. // }
  198. if (callback && thisArg) {
  199. callback.call(thisArg, re.data);
  200. }
  201. },
  202. fail: function (re) {
  203. wx.hideLoading();
  204. }
  205. })
  206. } else {
  207. wx.request({
  208. url: httpUrl,
  209. method: methods,
  210. header: {
  211. "OPENID": this.globalData.openid,
  212. "VERSION": '100'
  213. },
  214. success: function (re) {
  215. if (re.data.code == -1002) {
  216. wx.removeStorageSync('openid');
  217. // that.wxLogin();
  218. // that.wxRequest(url, params, callback, thisArg, methods, openid);
  219. }
  220. if (callback && thisArg) {
  221. callback.call(thisArg, re.data);
  222. }
  223. },
  224. fail: function (res) {
  225. wx.hideLoading();
  226. }
  227. })
  228. }
  229. },
  230. submitUserMsg: function (avatarUrl, nickName) {//提交用户信息
  231. this.wxRequest(this.globalData.urlRoot + "userInfo/updateUserInfo", { avatarUrl: avatarUrl, nickName: nickName }, res => {
  232. if (res.code == 200) {
  233. this.globalData.userInfoData = {};
  234. this.globalData.userInfoData.avatarUrl = avatarUrl;
  235. this.globalData.userInfoData.nickName = nickName;
  236. wx.setStorageSync('userInfoData', {
  237. avatarUrl: avatarUrl,
  238. nickName: nickName,
  239. userLevel:1
  240. })
  241. }
  242. }, this, "POST")
  243. },
  244. codeVerify: function (card) {//身份证号码验证
  245. 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]$)/;
  246. return rule.test(card);
  247. },
  248. mobileVerify: function (mobile) {//手机号验证
  249. let rule = /^1\d{10}$/;
  250. return rule.test(mobile);
  251. },
  252. callMobile: function (e) {//拨打电话
  253. wx.makePhoneCall({
  254. phoneNumber: e //仅为示例,并非真实的电话号码
  255. })
  256. },
  257. sharePack: function () {//分享
  258. return {
  259. title: '',
  260. imageUrl: "",
  261. path: "/pages/index/index"
  262. }
  263. },
  264. addformId: function (e) {//添加formid
  265. this.wxRequest(this.globalData.urlRoot + "/msg/addFormId", { formid: e }, res => {
  266. console.log(res.msg);
  267. }, this, "POST");
  268. },
  269. getMobile: function (encryptedData, iv, callback, thisArg) {//检查登录态是否过期
  270. wx.checkSession({
  271. success: res => {
  272. this.getMobile2(encryptedData,iv,callback,thisArg);
  273. },
  274. fail: res => {
  275. this.globalData.mobileData = {};
  276. this.globalData.mobileData.encryptedData = encryptedData;
  277. this.globalData.mobileData.iv = iv;
  278. this.globalData.mobileData.callback = callback;
  279. this.globalData.mobileData.thisArg = thisArg;
  280. this.wxLogin();
  281. }
  282. })
  283. },
  284. getMobile2: function (encryptedData, iv, callback, thisArg) {//和后台置换手机号
  285. this.globalData.mobileData = null;
  286. this.wxRequest(this.globalData.urlRoot + "userInfo/getUserPhoneNumber", { encryptedData: encryptedData, iv: iv }, res => {
  287. if (res.code == 200) {
  288. if (res.data && res.data.decodeData) {
  289. wx.setStorageSync('userMobile', res.data.decodeData.phoneNumber);
  290. this.globalData.userMobile = res.data.decodeData.phoneNumber;
  291. }
  292. }
  293. if (callback && thisArg) {
  294. callback.call(thisArg, res);
  295. }
  296. }, this, "POST");
  297. },
  298. getUserInfo: function () {//获取个人信息
  299. this.wxRequest(this.globalData.urlRoot +"userInfo/getUserInfo",{},res=>{
  300. if(res.code==200){
  301. if (res.data && res.data.avatarUrl) {
  302. this.globalData.userInfoData = {};
  303. this.globalData.userInfoData.avatarUrl = res.data.avatarUrl;
  304. this.globalData.userInfoData.nickName = res.data.nickName;
  305. this.globalData.userInfoData.userLevel = res.data.userLevel;
  306. wx.setStorageSync('userInfoData', {
  307. avatarUrl: res.data.avatarUrl,
  308. nickName: res.data.nickName,
  309. userLevel: res.data.userLevel
  310. })
  311. }
  312. }
  313. },this)
  314. },
  315. getBuyState: function () {//查询是否已下订
  316. this.wxRequest(this.globalData.urlRoot + "wxPay/getBuyState", {}, res => {
  317. if (res.code == 200) {
  318. if (res.data) {
  319. res.data.cdate = res.data.cdate ? res.data.cdate : "";
  320. this.globalData.getBuyState = res.data;
  321. if (this.globalData.buyStateSuccessFuc){
  322. this.globalData.buyStateSuccessFuc();
  323. }
  324. }
  325. }
  326. }, this);
  327. },
  328. addAppEnter: function () {//小程序整体pv统计
  329. this.wxRequest(this.globalData.urlRoot + "statistics/addAppEnter", { scene:this.globalData.sceneSource}, res => {
  330. }, this,"POST");
  331. },
  332. addPageEnter: function (e) {//小程序页面pv统计
  333. this.wxRequest(this.globalData.urlRoot + "statistics/addPageEnter", { scene: this.globalData.sceneSource, statisticsType:e }, res => {
  334. }, this, "POST");
  335. }
  336. })