Opinion.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const app = getApp();
  2. Page({
  3. data: {
  4. selectArray: [], // 性别-数据
  5. index: '', // 性别-下标、
  6. sex: '', // 性别
  7. },
  8. onLoad: function (options) {
  9. var that =this;
  10. // 性别 ajax
  11. let p_url = 'public/paramsgather?type=sex';
  12. let p_data = {
  13. // pid: '0'
  14. };
  15. app.postRequest(p_url, p_data, function (res) { // 性别 ajax
  16. if (res.code == 201) {
  17. // console.log(res.data);
  18. that.setData({
  19. selectArray: res.data
  20. })
  21. }
  22. // let dictObject = res.data;
  23. // // 对象转成数组
  24. // var createArr = []
  25. // for (let i in dictObject) {
  26. // createArr.push(dictObject[i]);
  27. // }
  28. })
  29. },
  30. onShow: function () {
  31. },
  32. GenderEvent: function (e) { // 性别 单项选择器
  33. // console.log(this);
  34. // console.log(e);
  35. // console.log(this.data.selectArray[e.detail.value]);
  36. // console.log('picker发送选择改变,携带值为', e.detail.value)
  37. this.setData({
  38. index: e.detail.value,
  39. sex: e.detail.value
  40. })
  41. },
  42. })