微信小程序
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.

293 rindas
5.6 KiB

  1. import * as UTIL from '../../utils/util.js';
  2. import * as API from '../../utils/API.js';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. //底部自定义tabbar
  9. isSHowZDYTabBar: true,
  10. //底部弹框显示
  11. showDownTS: true,
  12. list: [],
  13. isIPhoneX:false
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. let that = this;
  20. that.simulativeData();
  21. that.setData({
  22. isIPhoneX:UTIL.isIPhoneX()
  23. })
  24. },
  25. /**
  26. * 生命周期函数--监听页面初次渲染完成
  27. */
  28. onReady: function () {},
  29. /**
  30. * 生命周期函数--监听页面显示
  31. */
  32. onShow: function () {},
  33. /**
  34. * 生命周期函数--监听页面隐藏
  35. */
  36. onHide: function () {},
  37. /**
  38. * 生命周期函数--监听页面卸载
  39. */
  40. onUnload: function () {},
  41. /**
  42. * 页面相关事件处理函数--监听用户下拉动作
  43. */
  44. onPullDownRefresh: function () {},
  45. /**
  46. * 页面上拉触底事件的处理函数
  47. */
  48. onReachBottom: function () {},
  49. /**
  50. * 用户点击右上角分享
  51. */
  52. onShareAppMessage: function () {},
  53. onItemClickMethod: function (e) {
  54. var that = this;
  55. var num = parseInt(e.currentTarget.id);
  56. console.log(num)
  57. switch (num) {
  58. case 0:
  59. //更新机制
  60. break;
  61. case 1:
  62. //网络访问
  63. that.httpTestMethod();
  64. break;
  65. case 4:
  66. //获取地理位置
  67. that.getLocationInfo();
  68. break;
  69. case 5:
  70. //全局loading
  71. that.showLoadingIcon();
  72. break;
  73. case 6:
  74. that.showModalConentMethod();
  75. break;
  76. case 7:
  77. that.showModalAllMethod();
  78. break;
  79. case 8:
  80. that.showMoRenTab();
  81. break;
  82. case 9:
  83. that.showZDYTab();
  84. break;
  85. }
  86. },
  87. /**
  88. * 默认tab
  89. */
  90. showMoRenTab() {
  91. console.log('11111')
  92. wx.showTabBar({
  93. animation: false,
  94. })
  95. this.setData({
  96. isSHowZDYTabBar: true
  97. })
  98. }
  99. ,
  100. /**
  101. * 自定义tab
  102. */
  103. showZDYTab() {
  104. wx.hideTabBar({
  105. animation: false,
  106. })
  107. this.setData({
  108. isSHowZDYTabBar: false
  109. })
  110. }
  111. ,
  112. /**
  113. * 获取地理位置
  114. */
  115. getLocationInfo() {
  116. UTIL.getLocationFromWX(
  117. {
  118. success: (res) => {
  119. UTIL.showToastNoneIcon("当前经纬度:" + getApp().globalData.setInfo.latitude + "," + getApp().globalData.setInfo.longitude)
  120. }
  121. ,
  122. fail: (res) => {
  123. wx.navigateTo({
  124. url: '/pages/wxAuth/wxAuth',
  125. })
  126. }
  127. }
  128. );
  129. }
  130. ,
  131. /**
  132. * loading小图标
  133. */
  134. showLoadingIcon() {
  135. UTIL.showLoadingHaveMask('数据加载中...');
  136. setTimeout(function () {
  137. UTIL.hideLoadingHaveMask();
  138. }, 2000)
  139. }
  140. ,
  141. /**
  142. * 显示提示框
  143. */
  144. showModalConentMethod() {
  145. UTIL.showModalNoneCancel('温馨提示', '这是一个按钮的弹框', '知道了');
  146. },
  147. /**
  148. * 显示完整提示框 并监听
  149. */
  150. showModalAllMethod() {
  151. UTIL.showModalOnClick('提示', '两个按钮并回调', 'OK', 'NO',
  152. {
  153. confirm() {
  154. UTIL.showToastNoneIcon('点击了OK');
  155. }
  156. ,
  157. cancel() {
  158. UTIL.showToastNoneIcon('点击了NO');
  159. }
  160. });
  161. }
  162. ,
  163. //底部弹框允许
  164. okOnClick(e) {
  165. console.log("底部弹框-允许");
  166. UTIL.showToastNoneIcon("底部弹框-允许");
  167. this.setData({
  168. showDownTS: true
  169. })
  170. },
  171. /**
  172. * 底部弹框-黑色背景点击
  173. */
  174. blackOnClick() {
  175. this.setData({
  176. showDownTS: true
  177. })
  178. }
  179. ,
  180. /**
  181. * 底部弹框拒绝
  182. */
  183. refuseOnClick() {
  184. console.log("底部弹框-拒绝");
  185. UTIL.showToastNoneIcon("底部弹框-拒绝");
  186. this.setData({
  187. showDownTS: true
  188. })
  189. },
  190. bindgetUserProfile(e) {
  191. UTIL.getUserInfoFomWX({
  192. success(res){
  193. UTIL.showToastNoneIcon("获取到昵称:"+getApp().globalData.wxUserInfo.nickName);
  194. }
  195. });
  196. }
  197. ,
  198. /**
  199. * 网络访问
  200. */
  201. httpTestMethod() {
  202. let sendData = {
  203. centerShopId: 10000,
  204. centerWarehouseId: 10051,
  205. channel: 220,
  206. channelType: 22,
  207. memberId: 24892,
  208. rows: 40,
  209. shopId: 10005,
  210. token: "LWXAPP1636599316684iv6qkhyqhr4izg",
  211. v: 3,
  212. warehouseId: 10005
  213. }
  214. UTIL.httpRequest(API.URL_ZB_RECOMMEND_LIST, sendData,
  215. {
  216. success: (res) => {
  217. if (res._code == API.SUCCESS_CODE) {
  218. UTIL.showToastNoneIcon("数据共:" + res._data.length + "条");
  219. } else {
  220. UTIL.showToastNoneIcon(res._msg)
  221. }
  222. },
  223. fail: (res) => {
  224. UTIL.showToastNoneIcon(API.MSG_FAIL_HTTP)
  225. },
  226. complete: (res) => {
  227. }
  228. });
  229. }
  230. ,
  231. /**
  232. * 模拟数据
  233. */
  234. simulativeData() {
  235. let list = [
  236. {
  237. title: '更新机制(已嵌入)',
  238. },{
  239. title: '网络访问(点击获取)'
  240. },{
  241. title: '自动申请微信地理授权(已嵌入)'
  242. },{
  243. title: '获取微信OPenId(已嵌入)'
  244. },{
  245. title: '获取微信地理位置(点击获取)',
  246. tapBtn: 'getLocationInfo'
  247. },{
  248. title: 'loading小图标',
  249. tapBtn: 'showLoadingIcon'
  250. },{
  251. title: 'Modal弹框仅提示',
  252. tapBtn: 'showModalConentMethod',
  253. },{
  254. title: 'Modal两个按钮并监听',
  255. tapBtn: 'showModalAllMethod'
  256. },{
  257. title: '底部导航效果(默认)',
  258. tapBtn: 'showMoRenTab'
  259. },{
  260. title: '底部导航效果(自定义)',
  261. tapBtn: 'showZDYTab'
  262. }
  263. ];
  264. this.setData({
  265. list: list,
  266. })
  267. }
  268. })