index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. networker_id:data[0].shop[0]['value']
  106. })
  107. }
  108. }).catch(function (err) {
  109. console.log(err);
  110. })
  111. },
  112. /**
  113. * 生命周期函数--监听页面初次渲染完成
  114. */
  115. onReady: function () {
  116. const query = wx.createSelectorQuery()
  117. query.select('#nav').boundingClientRect((res) => {
  118. console.log(res);
  119. this.setData({
  120. selectInfo: res
  121. })
  122. })
  123. query.exec()
  124. },
  125. getData: function () {
  126. var that = this
  127. app.api.useApi(app.globalData.baseAppUrl + "api/admin/FactoryList", {
  128. device_id: deviceId,
  129. spout_device_id: spoutDeviceId
  130. }, "get").then(function (res) {
  131. console.log(res);
  132. if (res.code != 200) {
  133. wx.showLoading({
  134. title: res.message.msg,
  135. })
  136. setTimeout(function () {
  137. wx.hideLoading();
  138. }, 1000);
  139. } else {
  140. wx.hideLoading();
  141. var FactoryList = res.message.data.list
  142. for (var i in FactoryList) {
  143. that.data.factoryName.push(FactoryList[i].external_title)
  144. that.data.factoryId.push(FactoryList[i].id)
  145. }
  146. console.log(that.data.factoryName)
  147. that.setData({
  148. factoryName: that.data.factoryName,
  149. factoryId: that.data.factoryId,
  150. num,
  151. content: res.message.data.group
  152. })
  153. }
  154. }).catch(function (err) {
  155. console.log(222);
  156. })
  157. },
  158. saoma: function () {
  159. var that = this
  160. wx.scanCode({
  161. onlyFromCamera: true,
  162. success(res) {
  163. that.setData({
  164. orderSn: res.result
  165. })
  166. console.log(res.result)
  167. if(res.result.slice(0,4)=='http'){
  168. var regstra = new RegExp('(^|&|/?)network_id=([^&|/?]*)', 'i');
  169. var expa = res.result.match(regstra);
  170. console.log(expa[2]);
  171. var regstrb = new RegExp('(^|&|/?)orde_num=([^&|/?]*)', 'i');
  172. var expb = res.result.match(regstrb);
  173. console.log(expb[2]);
  174. wx.navigateTo({
  175. url: '/pages/signFor/storage?networkid='+expa[2]+'&ordernum='+expb[2],
  176. })
  177. }else{
  178. that.onSubmit()
  179. }
  180. }
  181. })
  182. },
  183. onSubmit: function () {
  184. var that = this
  185. if (that.data.orderSn == '')
  186. return wx.showToast({ title: '物流号不能为空', icon: 'none' })
  187. app.api.useApi(app.globalData.baseAppUrl + "api/admin/CodeSign", {
  188. order_no: that.data.orderSn,
  189. admin_type:that.data.admin_type,//1物流员;2代收点
  190. networker_id:that.data.networker_id,
  191. }, "post").then(function (res) {
  192. wx.hideLoading();
  193. if (res.code == 200)
  194. wx.showToast({ title: res.message.msg, icon: 'none' })
  195. else
  196. wx.showModal({
  197. title: '异常',
  198. content: res.message.msg,
  199. showCancel: false,
  200. success(res) {
  201. if (res.confirm) {
  202. console.log('用户点击确定')
  203. } else if (res.cancel) {
  204. console.log('用户点击取消')
  205. }
  206. }
  207. })
  208. if (that.data.checked)
  209. that.saoma()
  210. }).catch(function (err) {
  211. console.log(222);
  212. })
  213. },
  214. switchChange: function (e) {
  215. console.log(e)
  216. this.setData({
  217. checked: e.detail.value
  218. })
  219. }
  220. })