queue.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /**
  2. *
  3. * @author maxd
  4. * @date 2019.8.1
  5. */
  6. module.exports = {
  7. //微信公众号的appId
  8. getWxAppid() {
  9. return 'wxb793be4e9400d6f2'
  10. },
  11. //全局邀请码
  12. getInvitation() {
  13. return uni.getStorageSync("publicRelation")
  14. },
  15. //获取APP下载地址
  16. getAppDownUrl() {
  17. return uni.getStorageSync("appurl")
  18. },
  19. //全局域名 部分html中需要单独替换 需要修改config中的网络请求域名
  20. publicYuMing() {
  21. // return 'https://ptyh.xianmxkj.com'
  22. return 'https://shunfengche.xianmxkj.com'
  23. // return 'https://44a13m8485.goho.co'
  24. },
  25. getPingDuoDuoPid() {
  26. return uni.getStorageSync("pinduoduopid")
  27. },
  28. minMoney() {
  29. return uni.getStorageSync("minMoney") ? uni.getStorageSync("minMoney") : '0.3'
  30. },
  31. invitaionNum() {
  32. return uni.getStorageSync("invitaionNum")
  33. },
  34. maxMoney() {
  35. return uni.getStorageSync("maxMoney") ? uni.getStorageSync("maxMoney") : '0.7'
  36. },
  37. teamMoney() {
  38. return uni.getStorageSync("teamMoney")
  39. },
  40. cashMoney() {
  41. return uni.getStorageSync("cashMoney") ? uni.getStorageSync("cashMoney") : '10'
  42. },
  43. threeMoney() {
  44. return uni.getStorageSync("threeMoney")
  45. },
  46. logout() {
  47. this.remove("token");
  48. this.remove("userId");
  49. this.remove("mobile");
  50. this.remove("openid");
  51. this.remove("nickName");
  52. this.remove("relation");
  53. this.remove("image_url");
  54. this.remove("relation_id");
  55. },
  56. loginClear() {
  57. this.remove("token");
  58. this.remove("userId");
  59. this.remove("mobile");
  60. this.remove("nickName");
  61. this.remove("image_url");
  62. this.remove("relation_id");
  63. },
  64. showLoading(title) {
  65. uni.showLoading({
  66. title: title
  67. });
  68. },
  69. showToast(title) {
  70. uni.showToast({
  71. title: title,
  72. mask: false,
  73. duration: 2000,
  74. icon: "none"
  75. });
  76. },
  77. getSearchKeys: function(key) {
  78. let list = uni.getStorageSync("searchKeys");
  79. let keys = key.replace(/\s*/g, "")
  80. return list.indexOf(keys);
  81. },
  82. setJson: function(key, value) {
  83. let jsonString = JSON.stringify(value);
  84. try {
  85. uni.setStorageSync(key, jsonString);
  86. } catch (e) {
  87. // error
  88. }
  89. },
  90. setData: function(key, value) {
  91. try {
  92. uni.setStorageSync(key, value);
  93. } catch (e) {
  94. // error
  95. }
  96. },
  97. getData: function(key) {
  98. try {
  99. const value = uni.getStorageSync(key);
  100. if (value) {
  101. return value;
  102. }
  103. } catch (e) {
  104. // error
  105. }
  106. },
  107. getJson: function(key) {
  108. try {
  109. const value = uni.getStorageSync(key);
  110. if (value) {
  111. return JSON.parse(value);
  112. }
  113. } catch (e) {
  114. // error
  115. }
  116. },
  117. clear: function() {
  118. uni.clearStorage();
  119. },
  120. get: function(key) { //获取队列里面全部的数据
  121. let data = this.getJson(key);
  122. if (data instanceof Array) {
  123. return data;
  124. }
  125. return [];
  126. },
  127. insert: function(param) { //队列插入数据
  128. param.capacityNum = param.capacityNum || 100; //队列容量 默认队列中超过100条数据,自动删除尾部
  129. let data = this.getJson(param.key);
  130. if (data instanceof Array) {
  131. if (data.length > param.capacityNum) {
  132. let total = data.length - param.capacityNum;
  133. for (let i = 0; i < total; i++) {
  134. data.pop();
  135. }
  136. }
  137. data.unshift(param.value);
  138. } else {
  139. data = [];
  140. data.push(param.value);
  141. }
  142. this.setJson(param.key, data);
  143. },
  144. removeItem: function(key, itemIds) { //提供itemIds数组 批量删除队列中的某项数据
  145. let data = this.getJson(key);
  146. if (data instanceof Array) {
  147. for (let i = 0; i < itemIds.length; i++) {
  148. for (let p = 0; p < data.length; p++) {
  149. if (itemIds[i] === data[p].itemid) {
  150. data.splice(p, 1);
  151. break;
  152. }
  153. }
  154. }
  155. this.setJson(key, data);
  156. }
  157. },
  158. remove: function(key) { //删除某条队列
  159. try {
  160. uni.removeStorageSync(key);
  161. //localStorage.removeItem(key)
  162. } catch (e) {
  163. // error
  164. }
  165. }
  166. };