index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. // index.js
  2. //获取应用实例
  3. var app = getApp();
  4. Page({
  5. data: {
  6. urlHttp: '',
  7. contentList:[],
  8. command:'', //口令
  9. commandNeibu:'',
  10. commandPlaceholder: '请输入口令',
  11. showVip : false,
  12. showNeiBu:false,
  13. hiddenmodal : true //显示提示弹窗
  14. },
  15. onLoad: function () {
  16. var that = this;
  17. var host = getApp().globalData.servsers;
  18. that.setData({
  19. urlHttp: host
  20. });
  21. wx.request({
  22. url: host+"classifyapi/findAllforhome",
  23. data: {},
  24. method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
  25. header: {
  26. 'Accept': 'application/json'
  27. },
  28. success: function (res) {
  29. that.setData({
  30. contentList: res.data.rows
  31. });
  32. console.log(res.data.rows);
  33. if (res == null || res.data == null) {
  34. console.error('网络请求失败');
  35. return;
  36. }
  37. }
  38. })
  39. },
  40. //下拉刷新
  41. onPullDownRefresh: function (e) {
  42. this.onLoad();
  43. wx.stopPullDownRefresh();
  44. },
  45. //打开VIP弹窗
  46. openVipWind:function(e){
  47. var that = this;
  48. that.setData({
  49. showVip: true
  50. })
  51. },
  52. //关闭VIP弹窗
  53. closeVipWind:function(e){
  54. var that = this;
  55. that.setData({
  56. showVip: false
  57. })
  58. },
  59. //口令
  60. commandInput: function (e) {
  61. this.setData({
  62. command: e.detail.value
  63. })
  64. },
  65. commandInputFocus:function(e){
  66. var that = this;
  67. that.setData({
  68. commandPlaceholder : ''
  69. })
  70. },
  71. //vip - 立即进入
  72. comeInVip:function(e){
  73. var that = this;
  74. var command = that.data.command;
  75. if (command != 'VIPBYU'){
  76. that.setData({
  77. hiddenmodal: false,
  78. modalCont: '输入口令有误!请重新输入口令',
  79. })
  80. setTimeout(function () {
  81. that.setData({
  82. hiddenmodal: true,
  83. commandPlaceholder: '请输入口令'
  84. })
  85. }, 1000)
  86. return false;
  87. }else{
  88. that.setData({
  89. showVip: false,
  90. command : '',
  91. commandPlaceholder: '请输入口令'
  92. })
  93. setTimeout(function () {
  94. wx.navigateTo({
  95. url: '/pages/kindSecondList/kindSecondList?classify_name=VIP专区&classify_des=大良造VIP专区&id=2998',
  96. })
  97. }, 50)
  98. }
  99. },
  100. //打开内部员工弹窗
  101. openNeibuWind: function (e) {
  102. var that = this;
  103. that.setData({
  104. showNeibu: true
  105. })
  106. },
  107. //关闭内部员工弹窗
  108. closeNeibuWind: function (e) {
  109. var that = this;
  110. that.setData({
  111. showNeibu: false
  112. })
  113. },
  114. //内部员工口令
  115. commandNeibuInput: function (e) {
  116. this.setData({
  117. commandNeibu: e.detail.value
  118. })
  119. },
  120. commandNeibuInputFocus: function (e) {
  121. var that = this;
  122. that.setData({
  123. commandPlaceholder: ''
  124. })
  125. },
  126. //内部员工 - 立即进入
  127. comeInNeibu: function (e) {
  128. var that = this;
  129. var commandNeibu = that.data.commandNeibu;
  130. if (commandNeibu != 'maineibu') {
  131. that.setData({
  132. hiddenmodal: false,
  133. modalCont: '输入口令有误!请重新输入口令',
  134. })
  135. setTimeout(function () {
  136. that.setData({
  137. hiddenmodal: true,
  138. commandPlaceholder: '请输入口令'
  139. })
  140. }, 1000)
  141. return false;
  142. } else {
  143. that.setData({
  144. showNeibu: false,
  145. commandNeibu: '',
  146. commandPlaceholder: '请输入口令'
  147. })
  148. setTimeout(function () {
  149. wx.navigateTo({
  150. url: '/pages/kindSecondList/kindSecondList?classify_name=内部购买&classify_des=古德内部员工购买&id=3000&flag=0',
  151. })
  152. }, 50)
  153. }
  154. },
  155. })
  156. var that;
  157. var Util = require('../../utils/util.js');