panxingxin 5 rokov pred
rodič
commit
66830ccec5

+ 118 - 0
api/request.js

@@ -0,0 +1,118 @@
+var Fly = require("../lib/wx.umd.min") //wx.js is your downloaded code
+var fly = new Fly(); //Create an instance of Fly
+const app = getApp()
+
+//设置超时
+fly.config.timeout = 20000;
+
+// 获取白名单
+import whiteList from './whiteList';
+
+// Add interceptors
+fly.interceptors.request.use((request) => {
+  wx.showLoading({
+    title: '加载中',
+    mask: true
+  })
+  // 不显示加载页面的接口
+  if (whiteList.loading.indexOf(request.url) === -1) {
+    // 隐藏loading遮罩
+    wx.hideLoading();
+  }
+  // 请求资源服务器时,不添加token
+  if (whiteList.nullHeaderToken.indexOf(request.url) !== -1) {
+    request.timeout = 30000; // 请求超时
+    request.headers = {
+      'content-type': 'application/json',
+      'X-Tag': 'flyio'
+    };
+    console.log('nullHeaderToken()')
+    return request;
+  }
+  fly.lock()
+  // 延迟发请求 等 getStorageSync 存储
+  if(wx.getStorageSync('token')) {
+     // 给所有请求添加自定义header
+     request.timeout = 30000;
+     Object.assign(request.headers, {
+       'content-type': 'application/json',
+       'X-Tag': 'flyio',
+       'Authorization': `Bearer ${wx.getStorageSync('token')}`
+     })
+     fly.unlock(); //解锁请求
+     return request;
+  } else if (request.headers.Authorization) {
+    // 给所有请求添加自定义header
+    request.timeout = 30000;
+    Object.assign(request.headers, {
+      'content-type': 'application/json',
+      'X-Tag': 'flyio'
+    })
+    fly.unlock(); //解锁请求
+    return request;
+  }
+  //  else if(!wx.getStorageSync('token')&&app.getCurrentPages()=='pages/login/login') {
+  //   request.headers = {
+  //     'content-type': 'application/json',
+  //     'X-Tag': 'flyio',
+  //     'Authorization': 'Basic dGVzdDp0ZXN0'
+  //   };
+  //   fly.unlock();//解锁请求
+  //   return request;
+  // }
+  else {
+    setTimeout(() => {
+      wx.redirectTo({
+        url: '../login/login'
+      });
+    }, 300)
+  }
+}, (error, promise) => {
+  // Do something with request error
+  console.log(error); // for debug
+  promise.reject(error)
+});
+fly.interceptors.response.use(
+  (response) => {
+    wx.hideLoading();
+    //只将请求结果的data字段返回
+    return response
+  },
+  (err, promise) => {
+    wx.hideLoading();
+    let msg = '';
+    if (err.status === 0) {
+      msg = '网络连接异常'
+    } else if (err.status === 1) {
+      msg = '网络连接超时'
+    } else if (err.status === 401) {
+      msg = '用户未登录'
+      wx.clearStorageSync('token')
+      wx.redirectTo({
+        url: '../login/login'
+      });
+    } else {
+      if (err.response.data.message) {
+        msg = err.response.data.message
+      } else {
+        msg = '请求数据失败,请稍后再试'
+      }
+    }
+    wx.showToast({
+      title: msg,
+      icon: 'none',
+      duration: 3000
+    });
+    // setTimeout(() => {
+    //   console.log('fly.interceptors.err-toLogin')
+    //   wx.redirectTo({
+    //     url: '../login/login'
+    //   });
+    // }, 500)
+    return promise.resolve(err)
+  }
+)
+// Set the base url
+fly.config.baseURL = "http://192.168.20.52:9999"
+
+export default fly;

+ 14 - 0
api/whiteList.js

@@ -0,0 +1,14 @@
+export default {
+  // 不显示加载提示
+  loading: [
+    '/route/list'
+  ],
+  // 不重定向白名单
+  route: [
+    '/login'
+  ],
+  // 不带token的url
+  nullHeaderToken: [
+    '/user/weChatLogin'
+  ]
+}

+ 14 - 0
app.js

@@ -1,5 +1,19 @@
 //app.js
 App({
+  getCurrentPages: function () {
+    var pages = getCurrentPages(); //获取加载的页面
+    var currentPage = pages[pages.length - 1]; //获取当前页面的对象
+    var url = currentPage.route; //当前页面url
+    var options = currentPage.options; //获取url中所带的参数
+    //拼接url的参数
+    var currentPage = url + '?';
+    for (var key in options) {
+      var value = options[key]
+      currentPage += key + '=' + value + '&';
+    }
+    currentPage = currentPage.substring(0, currentPage.length - 1);
+    return currentPage;
+  },
   onLaunch: function () {
     // 展示本地存储能力
     var logs = wx.getStorageSync('logs') || []

+ 20 - 1
app.json

@@ -1,8 +1,27 @@
 {
   "pages": [
+    "pages/login/login",
     "pages/index/index",
-    "pages/bind/bind"
+    "pages/bind/bind",
+    "pages/sample/sample",
+    "pages/sample/list",
+    "pages/sample/detail"
   ],
+  "tabBar": {
+    "list": [
+      {
+        "pagePath": "pages/sample/sample",
+        "iconPath": "./resources/sample.png",
+        "selectedIconPath": "./resources/sample_selected.png",
+        "text": "样品单"
+      },{
+        "pagePath": "pages/index/index",
+        "iconPath": "./resources/contract.png",
+        "selectedIconPath": "./resources/contract_selected.png",
+        "text": "采购合同"
+      }
+    ]
+  },
   "window": {
     "backgroundTextStyle": "light",
     "navigationBarBackgroundColor": "#fff",

+ 17 - 1
app.wxss

@@ -5,6 +5,22 @@
   flex-direction: column;
   align-items: center;
   justify-content: space-between;
-  padding: 200rpx 0;
   box-sizing: border-box;
 } 
+.inputView {
+  display: flex;
+  background-color: #fff;
+}
+.btnView {
+  margin-top: 2rem;
+}
+.btnView button {
+  width: 90%!important;
+}
+.loginLab {
+  margin: 1rem;
+  color: #545454;
+}
+.inputText {
+  margin-top: 1rem;
+}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 295 - 0
components/icon/icon.js


+ 4 - 0
components/icon/icon.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 14 - 0
components/icon/icon.wxml

@@ -0,0 +1,14 @@
+<wxs module="utils">
+    var double = function(a) {
+        return 2*a
+    };
+    var ifSpecialIcon = function(v) {
+      return v === 'arrow' || v === 'back'
+    }
+    module.exports = {
+      double: double,
+      ifSpecialIcon: ifSpecialIcon
+    }
+</wxs>
+
+<view class="{{extClass}} weui-icon" style="background:{{color}};width:{{size}}px;height:{{ utils.ifSpecialIcon(icon) ? utils.double(size) : size}}px;mask-image:url({{src}});-webkit-mask-image:url({{src}});-moz-mask-image:url({{src}})"></view>

+ 1 - 0
components/icon/icon.wxss

@@ -0,0 +1 @@
+.weui-icon{vertical-align:middle;display:inline-block;background:black;mask-repeat:no-repeat;-webkit-mask-repeat:no-repeat;-moz-mask-repeat:no-repeat;mask-size:cover;-webkit-mask-size:cover;-moz-mask-size:cover}

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 1 - 0
lib/wx.umd.min.js


+ 108 - 0
models/dataModel.js

@@ -0,0 +1,108 @@
+import fly from '../api/request.js'
+
+// 用户登录
+export function userLogin(code) {
+  return fly.request({
+    url: '/auth/mobile/token/social?grant_type=mobil&mobile=MINI@'+code,
+    method: 'post',
+    headers:{
+      'Authorization': 'Basic dGVzdDp0ZXN0'
+    }
+  })
+}
+
+// 获取验证码
+export function getSmsCode(mobile) {
+  return fly.request({
+    url: '/admin/mobile/'+mobile,
+    method: 'get',
+    headers:{
+      'Authorization': 'Basic dGVzdDp0ZXN0'
+    }
+  })
+}
+
+// 输入验证码获取token
+export function getSmsToken(mobile, code) {
+  return fly.request({
+    url: `/auth/mobile/token/sms?mobile=SMS@${mobile}&code=${code}&grant_type=mobile`,
+    method: 'post',
+    headers:{
+      'Authorization': 'Basic dGVzdDp0ZXN0'
+    }
+  })
+}
+
+// 输入验证码获取token
+export function bindOpenId(code) {
+  return fly.request({
+    url: `/admin/social/bind?state=MINI&code=${code}`,
+    method: 'post'
+  })
+}
+
+// 获取用户信息,判断token是否过期
+export function getUserInfo() {
+  return fly.request({
+    url: '/admin/user/info',
+    method: 'get'
+  })
+}
+
+// 获取样品单列表
+export function getSampleList(form) {
+  return fly.request({
+    url: '/inventory/sample/page',
+    method: 'get',
+    params: form
+  })
+}
+
+// 获取样品单详情
+export function getSampleDetail(sdpId) {
+  return fly.request({
+    url: `/inventory/sample/${sdpId}`,
+    method: 'get'
+  })
+}
+
+// 获取样品单qa日志
+export function getSampleQaLog(sdpId) {
+  return fly.request({
+    url: `/inventory/sample/qalog/upload/${sdpId}`,
+    method: 'get'
+  })
+}
+
+// 修改样品单qa日志
+export function changeSampleQaLog(sdpId,mark) {
+  return fly.request({
+    url: `/inventory/sample/qalog/upload/picture?sdpId=${sdpId}&mark=${mark}`,
+    method: 'put'
+  })
+}
+
+// 添加样品单qa日志
+export function addSampleQaLog(sdpId,mark) {
+  return fly.request({
+    url: `/inventory/sample/qalog/upload/log?sdpId=${sdpId}&mark=${mark}`,
+    method: 'post'
+  })
+}
+
+// 添加qa图片
+export function addSamplePic(form) {
+  return fly.request({
+    url: `/inventory/sample/qalog/upload/picture?sdpId=${sdpId}`,
+    method: 'post',
+    data: form
+  })
+}
+
+// 删除qa图片
+export function delSamplePic(sdpId, url) {
+  return fly.request({
+    url: `/inventory/sample/qalog/upload/picture?sdpId=${sdpId}&url=${url}`,
+    method: 'delete'
+  })
+}

+ 0 - 4
pages/bind/bind.js

@@ -38,7 +38,6 @@ bind:function(e){
     },
     success(res) {
       var token = res.data.access_token
-     
       wx.login({
         success(res){
           wx.request({
@@ -53,9 +52,6 @@ bind:function(e){
           })
         }
       })
-
-
-
     }
   })
 },

+ 22 - 60
pages/index/index.js

@@ -4,68 +4,30 @@ const app = getApp()
 
 Page({
   data: {
-    username:'未登录'
+    nbFrontColor: '#000',
+    nbBackgroundColor: '#fff'
   },
-  getPhoneNumber (e) {
-    console.log(e.detail.errMsg)
-    console.log(e.detail.iv)
-    console.log(e.detail.encryptedData)
+  onLoad() {
+    this.setData({
+      nbTitle: 'test',
+      nbLoading: false,
+      nbFrontColor: '#fff',
+      nbBackgroundColor: '#000'
+    })
   },
   //事件处理函数
-  bindViewTap: function() {
-    wx.navigateTo({
-      url: '../logs/logs'
+  getmenu: function () {
+
+    wx.request({
+      url: 'http://192.168.20.53:9999/admin/menu/tree',
+      method: 'get',
+      header: {
+        'Authorization': 'Bearer ' + wx.getStorageSync('token')
+      },
+      success(r) {
+        console.log(r)
+        console.log(r)
+      }
     })
-  },
-
-
-  getmenu:function(){
-
-        wx.request({
-          url: 'http://192.168.20.53:9999/admin/menu/tree',
-          method: 'get',
-          header: {
-            'Authorization': 'Bearer '+wx.getStorageSync('token')
-          },
-          success(r) {
-            console.log(r)
-            console.log(r)
-          }
-        })
-  
-
-  },
-
-
-
-  login:function(){
-    // var self = this
-    // wx.login({
-    //   success(res){
-    //     wx.request({
-    //       url: 'http://192.168.20.53:9999/auth/mobile/token/social?grant_type=mobil&mobile=MINI@'+res.code,
-    //       method: 'post',
-    //       header: {
-    //         'Authorization': 'Basic dGVzdDp0ZXN0'
-    //       },
-    //       success(res){
-    //         console.log(res)
-    //         wx.setStorageSync('token', res.data.access_token);
-    //         if (res.statusCode === 401){
-    //            console.log(res.data)
-    //            wx.navigateTo({
-    //              url: '../bind/bind',
-    //            })
-    //         }else{
-    //           self.setData({
-    //             username: res.data.username
-    //           })
-    //         }
-    //       }
-    //     })
-    //   }
-    // })
-
   }
-
-})
+})

+ 0 - 13
pages/index/index.wxml

@@ -1,13 +0,0 @@
-<!--index.wxml-->
-<view class="container">
-  <view class="userinfo">
-<button bindgetphonenumber="getPhoneNumber" open-type="getPhoneNumber" type="primary">登录</button>
-
-<!-- <button bindtap="getmenu">获取菜单</button> -->
-
-
-  </view>
-  <view class="usermotto">
-    <text class="user-motto">{{username}}</text>
-  </view>
-</view>

+ 5 - 0
pages/index/index.wxss

@@ -5,6 +5,11 @@
   align-items: center;
 }
 
+image {
+  width: 10rem;
+  height: 10rem;
+}
+
 .userinfo-avatar {
   width: 128rpx;
   height: 128rpx;

+ 115 - 0
pages/login/login.js

@@ -0,0 +1,115 @@
+import * as requestAPI from '../../models/dataModel'
+import {
+  isPoneAvailable
+} from '../../utils/util'
+
+Page({
+  data: {
+    phone: '',
+    success: false,
+    code: '',
+    ifUser: true
+  },
+
+  onLoad() {
+    if(wx.getStorageSync('token')) {
+      this.getIfExpired()
+      wx.switchTab({
+        url: '/pages/sample/sample',
+      })
+    }
+  },
+  // 获取手机号号 
+  phoneInput: function (e) {
+    this.setData({
+      phone: e.detail.value
+    })
+  },
+
+  // 获取验证码
+  codeInput: function (e) {
+    this.setData({
+      code: e.detail.value
+    })
+  },
+
+  // 登录 
+  login: function () {
+    var self = this
+    wx.login({
+      success(wxres) {
+        console.log(wxres)
+        requestAPI.userLogin(wxres.code).then(res => {
+          console.log(res)
+          if (res.statusCode === 401) {
+            self.setData({
+              ifUser: false
+            })
+          } else {
+            if (res.data.access_token) {
+              wx.setStorageSync('token', res.data.access_token);
+              wx.switchTab({
+                url: '/pages/sample/sample',
+              })
+            }
+          }
+        })
+      }
+    })
+  },
+
+  register: function () {
+    let self = this
+    if (this.data.phone.length == 0) {
+      wx.showToast({
+        title: '手机不能为空',
+        icon: 'none',
+        duration: 3000
+      })
+    } else if (!isPoneAvailable(this.data.phone)) {
+      wx.showToast({
+        title: '请输入正确的手机号',
+        icon: 'none',
+        duration: 3000
+      })
+    } else {
+      requestAPI.getSmsCode(this.data.phone).then(res => {
+        if (isNaN(res.data.msg)) {
+          wx.showToast({
+            title: res.data.msg,
+            icon: 'none',
+            duration: 3000
+          })
+        } else {
+          self.setData({
+            code: res.data.msg
+          })
+          requestAPI.getSmsToken(self.data.phone, self.data.code).then(res => {
+            wx.setStorageSync('token', res.data.access_token)
+            wx.login({
+              success(wxres) {
+                console.log(wxres)
+                requestAPI.bindOpenId(wxres.code).then(res => {
+                  if (res.data.data === true) {
+                    self.setData({
+                      ifUser: true
+                    })
+                  }
+                })
+              },fail(res) {
+                wx.showToast({
+                  title: '验证失败',
+                  duration: 3000
+                })
+              }
+            })
+          })
+        }
+      })
+    }
+  },
+  getIfExpired() {
+    requestAPI.getUserInfo().then(res => {
+    })
+  }
+})

+ 7 - 0
pages/login/login.json

@@ -0,0 +1,7 @@
+{
+  "navigationBarTitleText": "登录",
+  "navigationBarBackgroundColor":"#fff",
+  "navigationBarTextStyle": "black",
+  "backgroundColor": "#eee",
+  "backgroundTextStyle": "light"
+}

+ 37 - 0
pages/login/login.wxml

@@ -0,0 +1,37 @@
+<view class="container">
+
+	<view class="login-icon">
+		<image class="login-img" src="../../resources/logo.png"></image>
+	</view>
+	<view class="login-form">
+
+		<!--账号-->
+		<view hidden="{{ifUser}}">
+			<view class="inputView">
+				<label class="loginLab">手机号:</label>
+				<input class="inputText" focus placeholder="请输入手机号" bindinput="phoneInput" />
+			</view>
+
+			<!--账号-->
+			<view class="inputView">
+				<label class="loginLab">验证码:</label>
+				<input class="inputText" value="{{code}}" focus placeholder="请输入验证码" bindinput="codeInput" />
+			</view>
+		</view>
+
+		<!-- <view class="line"></view> -->
+		<!--按钮-->
+		<view class="loginBtnView" hidden="{{!ifUser}}">
+			<button class="loginBtn" type="primary" bindtap="login">一键登录</button>
+		</view>
+		<view class="loginBtnView" hidden="{{ifUser}}">
+			<button class="loginBtn" type="primary" bindtap="register">注册</button>
+		</view>
+
+	</view>
+
+</view>
+
+<view class='success' wx:if="{{success}}">
+	<web-view src="{{text}}"></web-view>
+</view>

+ 87 - 0
pages/login/login.wxss

@@ -0,0 +1,87 @@
+page {
+  height: 100%;
+}
+
+.container {
+  height: 100%;
+  display: flex;
+  flex-direction: column;
+  padding: 0;
+  box-sizing: border-box;
+  background-color: #f2f2f2
+}
+
+/*登录图片*/
+.login-icon {
+  margin-top: 2rem;
+  flex: none;
+}
+
+.login-img {
+  width: 10rem;
+  height: 10rem;
+}
+
+/*表单内容*/
+.login-form {
+  margin-top: 2rem;
+  flex: auto;
+  height: 100%;
+}
+
+/* .inputView {
+  background-color: #fff;
+  line-height: 44px;
+} */
+
+.inputView:nth-child(1) {
+  border-bottom: 1px solid #ccc;
+}
+
+/*输入框*/
+.nameImage,
+.keyImage {
+  margin-left: 22px;
+  width: 14px;
+  height: 14px
+}
+
+/* .loginLab {
+  margin: 15px 15px 15px 10px;
+  color: #545454;
+  font-size: 14px
+} */
+
+/* .inputText {
+  flex: block;
+  float: right;
+  text-align: left;
+  margin-right: 22px;
+  margin-top: 11px;
+  font-size: 14px
+} */
+
+
+/*按钮*/
+.loginBtnView {
+  width: 100%;
+  height: auto;
+  background-color: #f2f2f2;
+  margin-top: 0px;
+  margin-bottom: 0px;
+  padding-bottom: 0px;
+}
+
+.loginBtn {
+  width: 100%;
+  margin-top: 1rem;
+}
+
+button {
+  width: unset !important;
+}
+
+.registerBtn {
+  width: 100%;
+  margin-top: 5px;
+}

+ 139 - 0
pages/sample/detail.js

@@ -0,0 +1,139 @@
+import * as requestAPI from '../../models/dataModel'
+Page({
+  data: {
+    sampleDetail: {},
+    mark: '',
+    tempMark: '',
+    sdpId: '',
+    imageList: []
+  },
+
+  onLoad: function (options) {
+    this.setData({
+      sdpId: options.sdpId
+    })
+    this.getDetail(options.sdpId)
+    this.getQaLog(options.sdpId)
+  },
+
+  // 获取样品单详情
+  getDetail(sdpId) {
+    requestAPI.getSampleDetail(sdpId).then(res => {
+      this.setData({
+        sampleDetail: res.data.data
+      })
+    })
+  },
+
+  // 获取qa日志
+  getQaLog(sdpId) {
+    requestAPI.getSampleQaLog(sdpId).then(res => {
+      if (res.data.data.length !== 0) {
+        this.setData({
+          mark: res.data.data[0].mark
+        })
+      }
+    })
+  },
+
+  getTempMark(e) {
+    this.setData({
+      tempMark: e.detail.value
+    })
+  },
+
+  // 保存或添加qa日志
+  saveQaLog(e) {
+    this.setData({
+      mark: e.detail.value
+    })
+    if (this.data.mark !== this.data.tempMark) {
+      if (this.data.tempMark) {
+        requestAPI.changeSampleQaLog(this.data.sdpId, this.data.mark).then(res => {
+          if (res.data.code === 0) {
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+              duration: 3000
+            })
+            setTimeout(() => {
+              this.getQaLog(this.data.sdpId)
+            }, 500)
+          }
+        })
+      } else {
+        requestAPI.addSampleQaLog(this.data.sdpId, this.data.mark).then(res => {
+          if (res.data.code === 0) {
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+              duration: 3000
+            })
+            setTimeout(() => {
+              this.getQaLog(this.data.sdpId)
+            }, 500)
+          }
+        })
+      }
+    }
+  },
+
+  // 拍照
+  takePhoto() {
+    this.getPhotos(1, 'camera')
+  },
+  choosePhoto() {
+    this.getPhotos(9, 'albumn')
+  },
+  getPhotos(count, type) {
+    let tempList = this.data.imageList
+    let _this = this
+    wx.chooseImage({
+      count: count,
+      sizeType: ['original', 'compressed'],
+      sourceType: [type],
+      success(res) {
+        for (let i of res.tempFilePaths) {
+          console.log(i)
+          wx.uploadFile({
+            url: `http://192.168.20.111:9999/inventory/sample/qalog/upload/picture?sdpId=${_this.data.sdpId}`, //此处换上你的接口地址 
+            filePath: i,
+            name: 'file',
+            header: {
+              "Content-Type": "multipart/form-data",
+              'Authorization': `Bearer ${wx.getStorageSync('token')}`,
+            },
+            success: function (res) {
+              console.log(res);
+              // let data = JSON.parse(res.data); // 这个很关键
+              // tempList.push(data.data.url);
+              // _this.setData({
+              //   imageList: tempList
+              // })
+            }
+          })
+        }
+        // for(let i of res.tempFilePaths) {
+        //   tempList.push(i)
+        // }
+        // _this.setData({
+        //   imageList: tempList
+        // })
+      }
+    })
+  },
+  delImg: function (event) {
+    console.log('s')
+    let tempList = this.data.imageList
+    tempList.splice(event.currentTarget.dataset.index, 1)
+    this.setData({
+      imageList: tempList
+    })
+  },
+  openPreview: function (event) {
+    wx.previewImage({
+      urls: this.data.imageList,
+      current: event.currentTarget.dataset.current
+    })
+  }
+})

+ 6 - 0
pages/sample/detail.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "mp-icon": "../../components/icon/icon"
+  },
+  "navigationBarTitleText": "样品单详情"
+}

+ 33 - 0
pages/sample/detail.wxml

@@ -0,0 +1,33 @@
+<view class="detail">
+	<view class="detail-item">
+		<label>我司货号:</label>
+		<input value="{{sampleDetail.sdpCode}}" />
+	</view>
+	<view class="detail-item">
+		<label>客户货号:</label>
+		<input value="{{sampleDetail.sdpCustomercode}}" />
+	</view>
+	<view class="detail-item">
+		<label>中文品名:</label>
+		<input value="{{sampleDetail.sdpCname}}" />
+	</view>
+	<view class="detail-item">
+		<label>Qa日志:</label>
+		<textarea value="{{mark}}" auto-height bindfocus="getTempMark" bindblur="saveQaLog" />
+		</view>
+	<view class="detail-item">
+		<label>图片:</label>
+		<view class="imageList">
+			<view class="image-item" wx:for="{{imageList}}" wx:key="index">
+				<icon type="cancel" size="10" bindtap="delImg" data-index="{{index}}"/>
+				<image src="{{item}}" mode="heightFix" bindtap="openPreview" data-current="{{item}}"></image>
+			</view>
+		</view>
+	</view>
+	<view class="detail-btns">
+		<view>
+			<mp-icon icon="camera" color="black" size="{{25}}" bindtap="takePhoto"></mp-icon>
+			<mp-icon icon="album" color="black" size="{{25}}" bindtap="choosePhoto"></mp-icon>
+		</view>
+	</view>
+</view>

+ 37 - 0
pages/sample/detail.wxss

@@ -0,0 +1,37 @@
+page{
+  background-color: #ebebeb;
+}
+.detail {
+  border-radius: 0.5rem;
+  background-color: #fff;
+  margin: 0.2rem;
+}
+.detail-item {
+  display: flex;
+  padding: 0.4rem;
+}
+.detail-item label {
+  width: 5rem;
+}
+.detail-item .imageList{
+  display: flex;
+  width: 100%;
+  flex-wrap: wrap;
+}
+.detail-item .imageList .image-item{
+  display: flex;
+  flex-direction: column;
+}
+.detail-item image {
+  height: 4rem;
+}
+.detail-btns {
+  display: flex;
+  justify-content: center;
+  padding: 0.5rem;
+}
+.detail-btns view{
+  display: flex;
+  width: 8rem;
+  justify-content: space-between;
+}

+ 66 - 0
pages/sample/list.js

@@ -0,0 +1,66 @@
+import * as requestAPI from '../../models/dataModel'
+Page({
+  data: {
+    sampleList: [],
+    sdDocument: '',
+    pCode: '',
+    current: 1,
+    size: 10,
+    total: 0
+  },
+  onLoad: function (options) {
+    this.setData({
+      pCode: options?options.pCode:this.data.pCode,
+      sdDocument: options?options.sdDocument:this.data.sdDocument
+    })
+    this.getSampleList()
+  },
+  // 获取样品单列表
+  getSampleList() {
+    wx.showLoading({title: '加载中', icon: 'loading'});
+    let form = {
+      current: this.data.current,
+      size: this.data.size,
+      sdDocument: this.data.sdDocument,
+      pCode: this.data.pCode
+    }
+    requestAPI.getSampleList(form).then(res => {
+      for (let i of res.data.data.records) {
+        i.pictureNum = i.pictures.length
+      }
+      this.setData({
+        sampleList: res.data.data.records,
+        total: res.data.data.total
+      })
+    })
+  },
+
+  // 获取样品单详情
+  getDetail: function (event) {
+    wx.navigateTo({
+      url: `/pages/sample/detail?sdpId=${event.currentTarget.dataset.id}`,
+    })
+  },
+
+  // 下拉刷新
+  onPullDownRefresh: function () {
+    wx.showNavigationBarLoading(); //在当前页面显示导航条加载动画
+    this.onLoad(); //刷新页面
+    setTimeout(function () {
+      wx.hideNavigationBarLoading(); //在当前页面隐藏导航条加载动画
+      wx.stopPullDownRefresh(); //停止下拉动作
+    }, 2000)
+  },
+
+  // 下拉加载
+  onReachBottom: function () {
+    if (this.data.size > this.data.total) {
+      return;
+    } else {
+      this.getSampleList();
+      this.setData({
+        size: this.data.size+10
+      })
+    }
+  }
+})

+ 6 - 0
pages/sample/list.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {},
+  "enablePullDownRefresh": true,
+  "onReachBottom": true,
+  "navigationBarTitleText": "样品单列表"
+}

+ 14 - 0
pages/sample/list.wxml

@@ -0,0 +1,14 @@
+<view class="list" hidden="{{showResult}}" wx:for="{{sampleList}}" wx:key="index" data-id="{{item.sdpId}}" bindtap="getDetail">
+	<view class="list-item">
+		<label>货号:</label>
+		<input value="{{item.pcode}}" disabled/>
+	</view>
+	<view class="list-item">
+		<label>样品单号:</label>
+		<input value="{{item.sdDocument}}" disabled/>
+	</view>
+	<view class="list-item">
+		<label>图片:</label>
+		<input value="{{item.pictureNum}}张" disabled/>
+	</view>
+</view>

+ 15 - 0
pages/sample/list.wxss

@@ -0,0 +1,15 @@
+page{
+  background-color: #ebebeb;
+}
+.list {
+  border-radius: 0.5rem;
+  background-color: #fff;
+  margin: 0.2rem;
+}
+.list-item {
+  display: flex;
+  padding: 0.4rem;
+}
+.list-item label {
+  width: 5rem;
+}

+ 25 - 0
pages/sample/sample.js

@@ -0,0 +1,25 @@
+Page({
+  data: {
+    sdDocument: '',
+    pCode: ''
+  },
+  onLoad() {},
+
+  bindDocumentInput: function (e) {
+    this.setData({
+      sdDocument: e.detail.value
+    })
+  },
+
+  bindpCodeInput: function (e) {
+    this.setData({
+      pCode: e.detail.value
+    })
+  },
+
+  search() {
+    wx.navigateTo({
+      url: `/pages/sample/list?sdDocument=${this.data.sdDocument}&pCode=${this.data.pCode}`,
+    })
+  }
+})

+ 4 - 0
pages/sample/sample.json

@@ -0,0 +1,4 @@
+{
+  "usingComponents": {},
+  "navigationBarTitleText": "样品单"
+}

+ 14 - 0
pages/sample/sample.wxml

@@ -0,0 +1,14 @@
+<view class="sample-search">
+	<view class="inputView">
+		<label class="loginLab">样品单号:</label>
+		<input class="inputText" focus placeholder="请输入样品单号" bindinput="bindDocumentInput"/>
+	</view>
+
+	<view class="inputView">
+		<label class="loginLab">我司货号:</label>
+		<input class="inputText" placeholder="请输入我司货号" bindinput="bindpCodeInput" />
+	</view>
+	<view class="btnView">
+		<button type="primary" bindtap="search">搜索</button>
+	</view>
+</view>

+ 0 - 0
pages/sample/sample.wxss


BIN
resources/contract.png


BIN
resources/contract_selected.png


BIN
resources/logo.png


BIN
resources/sample.png


BIN
resources/sample_selected.png


+ 11 - 1
utils/util.js

@@ -14,6 +14,16 @@ const formatNumber = n => {
   return n[1] ? n : '0' + n
 }
 
+const isPoneAvailable= phone => {
+  var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;
+  if (!myreg.test(phone)) {
+      return false;
+  } else {
+      return true;
+  }
+}
+
 module.exports = {
-  formatTime: formatTime
+  formatTime: formatTime,
+  isPoneAvailable: isPoneAvailable
 }