小程序模板网

微信小程序接受asp.net 返回的json值处理,判断是否是手机号,文字超过行后隐藏

发布时间:2018-02-06 15:33 所属栏目:小程序开发教程
 
 

	
  1. wx.request({
  2. url: 'https://l网址er.aspx',
  3. data: {
  4. openId: wx.getStorageSync('openId'),
  5. requestType: "query"
  6. },
  7. success: function (response) {
  8. //
  9. //console.log(response)
  10. //console.log(response.data)
  11. //console.log(response.statusCode)
  12. if (response.statusCode == '200') {
  13. var count = response.data.indexOf("\r\n\r\n<!DOC");
  14. var str = response.data.substring(0, count)
  15. var json = JSON.parse(str)
  16. //保存信息
  17. console.log(str+"长度" + json.length)
  18. } else {
  19. wx.showToast({
  20. title: '信息读取失败,请联系客服!',
  21. icon: 'success',
  22. duration: 1500
  23. })
  24. }
  25. }
  26. });
 

二:判断是否是手机号

 

	
  1. validatemobile: function (mobile) {
  2. if (mobile.length == 0) {
  3. wx.showToast({
  4. title: '请输入手机号!',
  5. icon: 'success',
  6. duration: 1500
  7. })
  8. return false;
  9. }
  10. if (mobile.length != 11) {
  11. wx.showToast({
  12. title: '手机号长度有误!',
  13. icon: 'success',
  14. duration: 1500
  15. })
  16. return false;
  17. }
  18. var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/;
  19. if (!myreg.test(mobile)) {
  20. wx.showToast({
  21. title: '手机号有误!',
  22. icon: 'success',
  23. duration: 1500
  24. })
  25. return false;
  26. }
  27. return true;
  28. }
 

三:文字超过行后隐藏显示省略号

 

	
  1. text{
  2.  
  3. overflow:hidden;
  4. //超出一行文字自动隐藏
  5.  
  6. text-overflow:ellipsis;//文字隐藏后添加省略号
  7.  
  8. white-space:nowrap;
  9. //强制不换行
  10.  
  11. }

或者多行的用这些:

 

	
  1. display: -webkit-box;
  2.  
  3. word-break: break-all;
  4.  
  5. text-overflow: ellipsis;
  6.  
  7. font-size: 32rpx;
  8.  
  9. overflow: hidden;
  10.  
  11. -webkit-box-orient: vertical;
  12.  
  13. -webkit-line-clamp:2;


易优小程序(企业版)+灵活api+前后代码开源 码云仓库:starfork
本文地址:https://www.eyoucms.com/wxmini/doc/course/21628.html 复制链接 如需定制请联系易优客服咨询:800182392 点击咨询
QQ在线咨询