index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. // pages/tabber/news/index.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. selectInfo: {},
  9. orderSn: '',
  10. checked: false,
  11. show: false,
  12. option1: [
  13. { text: '签收身份', value: 0 },
  14. { text: '物流员', value: 1 },
  15. { text: '代收点', value: 2 },
  16. ],
  17. city: [
  18. { text: '城市', value: 'a' },
  19. { text: '北京', value: 'b' },
  20. { text: '武汉', value: 'c' },
  21. ],
  22. columns: [
  23. { text: '网点', value: 'a' },
  24. { text: '好评排序', value: 'b' },
  25. { text: '销量排序', value: 'c' },
  26. ],
  27. value1:1,
  28. value2: 'a',
  29. value3: 'a',
  30. network:0,
  31. admin_type:1,
  32. networker_id:0,
  33. },
  34. /**
  35. * 生命周期函数--监听页面加载
  36. */
  37. onLoad: function (options) {
  38. class Select {
  39. in = 1
  40. getSelet() {
  41. console.log(2);
  42. return 10
  43. }
  44. }
  45. var b = new Select();
  46. console.log(b.getSelet());
  47. this.getcityoth()
  48. },
  49. Change(event) {
  50. const { picker, value, index } = event.detail;
  51. this.setData({
  52. admin_type: event.detail,
  53. })
  54. },
  55. Change2(event) {
  56. const { picker, value, index } = event.detail;
  57. this.setData({
  58. admin_type: event.detail,
  59. })
  60. },
  61. Change3(event) {
  62. const { picker, value, index } = event.detail;
  63. this.setData({
  64. networker_id: event.detail,
  65. })
  66. },
  67. show() {
  68. this.setData({
  69. show: !this.data.show
  70. })
  71. },
  72. onClose() {
  73. this.setData({
  74. show: !this.data.show
  75. })
  76. },
  77. //h获取顶部 城市身份等信息
  78. getcityoth() {
  79. var that = this
  80. app.api.useApi(app.globalData.baseAppUrl + "api/admin/ProvinceShop", {
  81. }, "get").then(function (res) {
  82. if (res.code != 200) {
  83. wx.showLoading({
  84. title: res.message.msg,
  85. })
  86. setTimeout(function () {
  87. wx.hideLoading();
  88. }, 1000);
  89. } else {
  90. wx.hideLoading();
  91. var data = res.message.data
  92. console.log(data)
  93. var city = [];
  94. var columns ={};
  95. for (var i=0;i<data.length;i++) {
  96. city[i] = { value: data[i].city_id, text: data[i].name }
  97. columns[data[i].city_id]= data[i].shop;
  98. }
  99. that.setData({
  100. city: city,
  101. columns: columns,
  102. network:data[0].shop,
  103. value2:data[0].city_id,
  104. value3:data[0].shop[0].value
  105. })
  106. }
  107. }).catch(function (err) {
  108. console.log(err);
  109. })
  110. },
  111. /**
  112. * 生命周期函数--监听页面初次渲染完成
  113. */
  114. onReady: function () {
  115. const query = wx.createSelectorQuery()
  116. query.select('#nav').boundingClientRect((res) => {
  117. console.log(res);
  118. this.setData({
  119. selectInfo: res
  120. })
  121. })
  122. query.exec()
  123. },
  124. getData: function () {
  125. var that = this
  126. app.api.useApi(app.globalData.baseAppUrl + "api/admin/FactoryList", {
  127. device_id: deviceId,
  128. spout_device_id: spoutDeviceId
  129. }, "get").then(function (res) {
  130. console.log(res);
  131. if (res.code != 200) {
  132. wx.showLoading({
  133. title: res.message.msg,
  134. })
  135. setTimeout(function () {
  136. wx.hideLoading();
  137. }, 1000);
  138. } else {
  139. wx.hideLoading();
  140. var FactoryList = res.message.data.list
  141. for (var i in FactoryList) {
  142. that.data.factoryName.push(FactoryList[i].external_title)
  143. that.data.factoryId.push(FactoryList[i].id)
  144. }
  145. console.log(that.data.factoryName)
  146. that.setData({
  147. factoryName: that.data.factoryName,
  148. factoryId: that.data.factoryId,
  149. num,
  150. content: res.message.data.group
  151. })
  152. }
  153. }).catch(function (err) {
  154. console.log(222);
  155. })
  156. },
  157. saoma: function () {
  158. var that = this
  159. wx.scanCode({
  160. onlyFromCamera: true,
  161. success(res) {
  162. that.setData({
  163. orderSn: res.result
  164. })
  165. that.onSubmit()
  166. }
  167. })
  168. },
  169. onSubmit: function () {
  170. var that = this
  171. if (that.data.orderSn == '')
  172. return wx.showToast({ title: '物流号不能为空', icon: 'none' })
  173. app.api.useApi(app.globalData.baseAppUrl + "api/admin/CodeSign", {
  174. order_no: that.data.orderSn,
  175. admin_type:that.data.admin_type,//1物流员;2代收点
  176. networker_id:that.data.networker_id,
  177. }, "post").then(function (res) {
  178. wx.hideLoading();
  179. if (res.code == 200)
  180. wx.showToast({ title: res.message.msg, icon: 'none' })
  181. else
  182. wx.showModal({
  183. title: '异常',
  184. content: res.message.msg,
  185. showCancel: false,
  186. success(res) {
  187. if (res.confirm) {
  188. console.log('用户点击确定')
  189. } else if (res.cancel) {
  190. console.log('用户点击取消')
  191. }
  192. }
  193. })
  194. if (that.data.checked)
  195. that.saoma()
  196. }).catch(function (err) {
  197. console.log(222);
  198. })
  199. },
  200. switchChange: function (e) {
  201. console.log(e)
  202. this.setData({
  203. checked: e.detail.value
  204. })
  205. }
  206. })