queue.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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://shunfengcheshop.xianmxkj.com'
  22. },
  23. //全局域名 部分html中需要单独替换 需要修改config中的网络请求域名
  24. publicYuMingAll() {
  25. return 'https://shunfengcheshop.xianmxkj.com/sqx_fast'
  26. },
  27. minMoney() {
  28. return uni.getStorageSync("minMoney") ? uni.getStorageSync("minMoney") : '0.3'
  29. },
  30. invitaionNum() {
  31. return uni.getStorageSync("invitaionNum")
  32. },
  33. maxMoney() {
  34. return uni.getStorageSync("maxMoney") ? uni.getStorageSync("maxMoney") : '0.7'
  35. },
  36. teamMoney() {
  37. return uni.getStorageSync("teamMoney")
  38. },
  39. goOpenLocation(latitude, longitude, name) {
  40. // 一键导航
  41. uni.openLocation({
  42. latitude: Number(latitude), //要去的纬度-地址
  43. longitude: Number(longitude), //要去的经度-地址
  44. name: name, //地址名称
  45. address: name, //详细地址名称
  46. success: function() {
  47. console.log('导航成功');
  48. },
  49. fail: function(error) {
  50. console.log(error)
  51. }
  52. })
  53. },
  54. logout() {
  55. this.remove("token");
  56. this.remove("userId");
  57. this.remove("mobile");
  58. this.remove("openid");
  59. this.remove("nickName");
  60. this.remove("relation");
  61. this.remove("avatar");
  62. this.remove("relation_id");
  63. this.remove("isInvitation");
  64. this.remove("member");
  65. this.remove("sex");
  66. },
  67. loginClear() {
  68. this.remove("token");
  69. this.remove("userId");
  70. this.remove("mobile");
  71. this.remove("nickName");
  72. this.remove("avatar");
  73. this.remove("relation_id");
  74. this.remove("isInvitation");
  75. this.remove("member");
  76. this.remove("sex");
  77. },
  78. showLoading(title) {
  79. uni.showLoading({
  80. title: title
  81. });
  82. },
  83. showToast(title) {
  84. uni.showToast({
  85. title: title,
  86. mask: false,
  87. duration: 4000,
  88. icon: "none"
  89. });
  90. },
  91. getSearchKeys: function(key) {
  92. let list =
  93. "套套,情趣用品,避孕,男用,女用,成人用品,保健品,冈本 杜蕾斯 杰士邦 第六感 倍力乐 诺丝 多乐士 斯香妮 双一 雨蝶 玛尼仕,充气娃娃,娃娃充气 阴蒂 刺激 超薄 螺纹 震动 润滑 女液体 延时 ";
  94. return list.includes(key);
  95. },
  96. setJson: function(key, value) {
  97. let jsonString = JSON.stringify(value);
  98. try {
  99. uni.setStorageSync(key, jsonString);
  100. } catch (e) {
  101. // error
  102. }
  103. },
  104. setData: function(key, value) {
  105. try {
  106. uni.setStorageSync(key, value);
  107. } catch (e) {
  108. // error
  109. }
  110. },
  111. getData: function(key) {
  112. try {
  113. const value = uni.getStorageSync(key);
  114. if (value) {
  115. return value;
  116. }
  117. } catch (e) {
  118. // error
  119. }
  120. },
  121. getJson: function(key) {
  122. try {
  123. const value = uni.getStorageSync(key);
  124. if (value) {
  125. return JSON.parse(value);
  126. }
  127. } catch (e) {
  128. // error
  129. }
  130. },
  131. clear: function() {
  132. uni.clearStorage();
  133. },
  134. get: function(key) { //获取队列里面全部的数据
  135. let data = this.getJson(key);
  136. if (data instanceof Array) {
  137. return data;
  138. }
  139. return [];
  140. },
  141. insert: function(param) { //队列插入数据
  142. param.capacityNum = param.capacityNum || 100; //队列容量 默认队列中超过100条数据,自动删除尾部
  143. let data = this.getJson(param.key);
  144. if (data instanceof Array) {
  145. if (data.length > param.capacityNum) {
  146. let total = data.length - param.capacityNum;
  147. for (let i = 0; i < total; i++) {
  148. data.pop();
  149. }
  150. }
  151. data.unshift(param.value);
  152. } else {
  153. data = [];
  154. data.push(param.value);
  155. }
  156. this.setJson(param.key, data);
  157. },
  158. removeItem: function(key, itemIds) { //提供itemIds数组 批量删除队列中的某项数据
  159. let data = this.getJson(key);
  160. if (data instanceof Array) {
  161. for (let i = 0; i < itemIds.length; i++) {
  162. for (let p = 0; p < data.length; p++) {
  163. if (itemIds[i] === data[p].itemid) {
  164. data.splice(p, 1);
  165. break;
  166. }
  167. }
  168. }
  169. this.setJson(key, data);
  170. }
  171. },
  172. isExist: function(key, itemId) { //检测某条数据在队列中是否存在
  173. let data = this.getJson(key);
  174. if (data instanceof Array) {
  175. for (let p = 0; p < data.length; p++) {
  176. if (itemId === data[p].itemid) {
  177. return true;
  178. }
  179. }
  180. }
  181. return false;
  182. },
  183. isExistPdd: function(key, itemId) { //检测某条数据在队列中是否存在
  184. let data = this.getJson(key);
  185. if (data instanceof Array) {
  186. for (let p = 0; p < data.length; p++) {
  187. if (itemId === data[p].goodsId) {
  188. return true;
  189. }
  190. }
  191. }
  192. return false;
  193. },
  194. isExistJd: function(key, itemId) { //检测某条数据在队列中是否存在
  195. let data = this.getJson(key);
  196. if (data instanceof Array) {
  197. for (let p = 0; p < data.length; p++) {
  198. if (itemId === data[p].skuId) {
  199. return true;
  200. }
  201. }
  202. }
  203. return false;
  204. },
  205. remove: function(key) { //删除某条队列
  206. try {
  207. uni.removeStorageSync(key);
  208. //localStorage.removeItem(key)
  209. } catch (e) {
  210. // error
  211. }
  212. },
  213. getCount: function(key) { //获取队列中全部数据数量
  214. let data = this.getJson(key);
  215. if (data instanceof Array) {
  216. return data.length;
  217. }
  218. return 0;
  219. },
  220. };