123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- // pages/order/custommanage/custommanage.js
- let util = require('../../../utils/util.js');
- let pyutil = require('../../../utils/pinyin.js');
- var that
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- customs: [],
- jumpNum: '',
- tel: ''
- },
- settel(e) {
- this.setData({
- tel: e.detail.value
- })
- },
- select(e) {
- var u = e.currentTarget.dataset
- let pages = getCurrentPages()
- let prevPage = pages[pages.length - 2]
- prevPage.setData({
- addressname: u.name,
- customerid: u.cuid,
- customeronlyid: u.cuonlyid,
- addressid: u.id,
- addressonlyid: u.onlyid
- })
- prevPage.updatelast(u.cuid)
- wx.navigateBack({
- delta: 1
- })
- },
- todetail(e) {
- wx.navigateTo({
- url: '/pages/order/customdetail/customdetail?id=' + e.currentTarget.dataset.id,
- })
- },
- toadd() {
- wx.navigateTo({
- url: '/pages/order/addcustom/addcustom',
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- that = this
- //pyutil.getPinYinFirstCharacter('?吧#:&')
- this.getAllCustom()
- },
- getAllCustom() {
- util.query('customeraddress/wxapi/listpage', {
- pageNo: 1,
- pageSize: 9999,
- name: this.data.tel
- }, function(res) {
- if (res.code === 10000) {
- var da = res.data.content
- var pys = []
- for (var i in da) {
- var py = pyutil.getPinYinFirstCharacter(da[i].name).toUpperCase().substr(0, 1)
- py = util.checkABC(py) ? py : '其他'
- var isfind = false
- for (var j in pys) {
- if (pys[j].py === py) {
- isfind = true
- pys[j].data.push(da[i])
- }
- }
- if (!isfind) {
- pys.push({
- py: py,
- data: [da[i]]
- })
- }
- }
- // pys = Object.keys(pys).sort(function(a, b) {
- // return pys[b].py - pys[a].py;
- // });
- // var sorted_keys_array = Object.keys(pys).sort((a, b) => {
- // return datas[b].py - datas[a].py;
- // });
- pys = pys.sort(function(a, b) {
- return a.py.charCodeAt() - b.py.charCodeAt()
- })
- that.setData({
- customs: pys
- })
- } else {
- that.setData({
- customs: []
- })
- }
- })
- },
- setjumpNum(e) {
- this.setData({
- jumpNum: e.currentTarget.dataset.index
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|