zoukankan      html  css  js  c++  java
  • dashucoding记录2019.6.8

    WordPress网站

    网址: https://cn.wordpress.org/

    阿里云市场
    https://market.aliyun.com/products/53616009?spm=a2c4e.11153940.blogcont160877.13.5e1f6ce7n0PL2Z&tag=WordPress&jianzhanSoft=%E5%8D%9A%E5%AE%A2

    将解压缩后的文件上传到 Linux 实例中的 alidata/www/phpwind 目录下

    云服务器 ECS 实例搭建 WordPres

    选购云服务器ECS
    选择点击“从镜像市场选择”

    1、购买阿里云ECS主机

    2、购买域名

    3、申请备案

    4、环境配置

    5、安装wordpress

    6、域名解析

    必须先将域名备案,才能通过域名访问阿里云的服务器

    image.png

    首先打开网址:http://www.aliyun.com/

    image.png

    阿里的云翼计划
    网址:https://promotion.aliyun.com/ntms/act/campus2018.html

    image.png

    注册域名

    image.png

    免费云解析:https://help.aliyun.com/document_detail/29716.html?spm=a2c4g.11186623.6.552.67257cd2w3N5EL

    一台阿里云服务器
    二个域名

    安装nginx,mysql,php
    获取lnmp一键安装包链接

    lnpm官网链接
    image.png

    小程序注册页面:

    image.png

    Page({
    data: {
        text: '获取验证码', //按钮文字
        currentTime: 61, //倒计时
        disabled: false, //按钮是否禁用
        phone: '', //获取到的手机栏中的值
        VerificationCode: '',
        Code: '',
        NewChanges: '',
        NewChangesAgain: '',
        success: false,
        state: '0',
        url: ''
      },
      /**
        * 获取验证码
        */
      return_home: function (e) {
        wx.navigateTo({
          url: '/pages/register/register',
        })
     
      },
      handleInputPhone: function (e) {
        this.setData({
          phone: e.detail.value
        })
      },
      handleVerificationCode: function (e) {
        console.log(e);
        this.setData({
          Code: e.detail.value
        })
      },
      handleNewChanges: function (e) {
        console.log(e);
        this.setData({
          NewChanges: e.detail.value
        })
      },
      handleNewChangesAgain: function (e) {
        console.log(e);
        this.setData({
          NewChangesAgain: e.detail.value
        })
     
      },
      doGetCode: function () {
        var that = this;
        that.setData({
          disabled: true, //只要点击了按钮就让按钮禁用 (避免正常情况下多次触发定时器事件)
          color: '#ccc',
        })
     
        var phone = that.data.phone;
        var currentTime = that.data.currentTime //把手机号跟倒计时值变例成js值
        var warn = null; //warn为当手机号为空或格式不正确时提示用户的文字,默认为空
    wx.request({
          url: 'http://192.168.41.40:8002/isExist', //后端判断是否已被注册, 已被注册返回1 ,未被注册返回0
          method: "GET",
          header: {
            'content-type': 'application/x-www-form-urlencoded'
          },
          success: function (res) {
            that.setData({
              state: res.data
            })
            if (phone == '') {
              warn = "号码不能为空";
            } else if (phone.trim().length != 11 || !/^1[3|4|5|6|7|8|9]d{9}$/.test(phone)) {
              warn = "手机号格式不正确";
            } //手机号已被注册提示信息
            else if (that.data.state == 1) {  //判断是否被注册
              warn = "手机号已被注册";
     
            }
            else {
              wx.request({
                url: 'http:///sendCode', //填写发送验证码接口
                method: "POST",
                data: {
                  coachid: that.data.phone
                },
                header: {
                  'content-type': 'application/x-www-form-urlencoded'
                },
                success: function (res) {
                  console.log(res.data)
                  that.setData({
                    VerificationCode: res.data.verifycode
                  })
     
     
                  //当手机号正确的时候提示用户短信验证码已经发送
                  wx.showToast({
                    title: '短信验证码已发送',
                    icon: 'none',
                    duration: 2000
                  });
                  //设置一分钟的倒计时
                  var interval = setInterval(function () {
                    currentTime--; //每执行一次让倒计时秒数减一
                    that.setData({
                      text: currentTime + 's', //按钮文字变成倒计时对应秒数
     
                    })
             
                    if (currentTime <= 0) {
                      clearInterval(interval)
                      that.setData({
                        text: '重新发送',
                        currentTime: 61,
                        disabled: false,
                        color: '#33FF99'
                      })
                    }
                  }, 100);
                }
              })
            };
            
            if (warn != null) {
              wx.showModal({
                title: '提示',
                content: warn
              })
              that.setData({
                disabled: false,
                color: '#33FF99'
              })
              return;
            }
          }
     
        })
     
      },
      submit: function (e) {
        var that = this
        if (this.data.Code == '') {
          wx.showToast({
            title: '请输入验证码',
            image: '/images/error.png',
            duration: 2000
          })
          return
        } else if (this.data.Code != this.data.VerificationCode) {
          wx.showToast({
            title: '验证码错误',
            image: '/images/error.png',
            duration: 2000
          })
          return
        }
        else if (this.data.NewChanges == '') {
          wx.showToast({
            title: '请输入密码',
            image: '/images/error.png',
            duration: 2000
          })
          return
        } else if (this.data.NewChangesAgain != this.data.NewChanges) {
          wx.showToast({
            title: '两次密码不一致',
            image: '/images/error.png',
            duration: 2000
          })
          return
        } else {
          var that = this
          var phone = that.data.phone;
          wx.request({
            url: 'http:///register',
            method: "POST",
            data: {
              coachid: phone,
              coachpassword: that.data.NewChanges
            },
            header: {
              "content-type": "application/x-www-form-urlencoded"
            },
            success: function (res) {
              wx.showToast({
                title: '提交成功~',
                icon: 'loading',
                duration: 2000
              })
              console.log(res.data)
              that.setData({
                success: true,
                url: res.data
              })
            }
          })
        }
      },
      /**
       * 用户点击右上角分享
       */
      onShareAppMessage: function () {
     
      }
    })
    

    image.png

    Page({
      data: {
        phone: '',
        password: '',
        success: false,
        text: ''
     
      },
     
      // 获取输入账号 
      phoneInput: function (e) {
        this.setData({
          phone: e.detail.value
        })
      },
     
      // 获取输入密码 
      passwordInput: function (e) {
        this.setData({
          password: e.detail.value
        })
      },
     
      // 登录 
      login: function () {
        var that = this;   
     
        var warn = null; 
        if (that.data.phone.length == 0) {
          wx.showToast({
            title: '用户名不能为空',
            icon: 'loading',
            duration: 1000
          })
        } else if (that.data.password.length == 0) {
          wx.showToast({
            title: '密码不能为空',
            icon: 'loading',
            duration: 1000
          })
        }else {
          
          wx.request({
            url: 'http:///login',
            method: "POST",
            data: {
              cardNo: that.data.phone,
              password: that.data.password
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              if (res.data.state == 1) {  //判断是否能正常登录
                warn = "卡号密码不匹配";
                wx.showModal({
                  title: '提示',
                  content: warn
                })
                return;
              } else {
                that.setData({
                  success: true,
                  text: res.data.url
                })
              }
            }
     
          })
     
     
     
        }
      },
      // 注册 
      register: function () {
        wx.navigateTo({
          url: '/pages/register/register',
        })
      }
     
    })
    

    转发功能

    open-type="share"`
    

    小程序分享或转发有两种方式

    onShareAppMessage: function (ops) {
       if (ops.from === 'button') {
         // 来自页面内转发按钮
         console.log(ops.target)
       }
       return {
         title: 'xx小程序',
         path: 'pages/index/index',
         success: function (res) {
           // 转发成功
           console.log("转发成功:" + JSON.stringify(res));
         },
         fail: function (res) {
           // 转发失败
           console.log("转发失败:" + JSON.stringify(res));
         }
       }
    
     }
    

    image.png

    如何通过经纬度查询到用户的当前位置成了一个问题

    申请腾讯地图密钥(key),申请地址:申请密钥

    image.png

    wx.getLocation({
          type: 'wgs84',
          success: function (res) {
            //console.log("获取当前经纬度:" + JSON.stringify(res));
            //发送请求通过经纬度反查地址信息  
            var getAddressUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + res.latitude + "," + res.longitude + "&key=你的key值&get_poi=1";
            common.Request(getAddressUrl, "get", "", function (ops) {
              //console.log(JSON.stringify(ops)); 
            })
          }
        }) 
    

    请点赞!因为你的鼓励是我写作的最大动力!

    官方微信公众号

    吹逼交流群:711613774

    吹逼交流群

  • 相关阅读:
    Leetcode题目322.零钱兑换(动态规划-中等)
    Leetcode题目292.Nim游戏(脑筋急转弯)
    Leetcode题目300.最长上升子序列(动态规划-中等)
    Leetcode题目287.寻找重复数(中等)
    Android学习笔记---初识eventbus
    Android学习笔记----实现卡牌翻转动画
    Android学习笔记----在Android使用ping来检测网络是否可用
    Android学习笔记----初体验ButterKnife框架
    Android 学习笔记---使用shell命令来关闭和开启ADB
    Android学习笔记--客户端上传图片到PHP服务器(带PHP端代码)
  • 原文地址:https://www.cnblogs.com/dashucoding/p/11140214.html
Copyright © 2011-2022 走看看