12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- var app = getApp()
- var that;
- Page({
- data: {
- list: [],
- page: 1,
- image: '',
- sn: '',
- },
- onLoad() {
- that = this;
- dd.setNavigationBar({ title: "兑换记录" });
- this.getData();
- },
- openDetail(e) {
- var id = e.target.dataset.item.id;
- dd.navigateTo({
- url: '../prizeDetail/prizeDetail?id=' + id + '&is=1'
- })
- },
- showText(e) {
- if (e.target.dataset.item) {
- var id = e.target.dataset.item.id;
- app.$get('api/shop/exchange/qrcode', { id: id, employee_id: app.globalData.userData.id }).then((res) => {
- this.setData({
- image: app.globalData.baseUrl + res.data.data,
- sn: e.target.dataset.item.sn
- })
- })
- }
- this.setData({
- isBh: !this.data.isBh,
- })
- },
- handleCopy() {
- dd.setClipboard({
- text: this.data.sn,
- })
- app.globalData.showToast("已复制");
- },
- //上啦加载
- onScrollToLower() {
- if (!that.data.isData) {
- this.setData({ page: ++that.data.page })
- this.getData(true);
- }
- },
- getData(is) {
- var data = {
- page: this.data.page,
- page_size: 20,
- export: 0,
- self_only: 1,
- }
- app.$get('api/shop/exchange/list', data).then((res) => {
- var data = res.data.data.list;
- // var data = [{ "id": 12, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "Rbyz1GyicvA=", "status": 2, "goods_id": 2, "cancel_remark": "我不行要了", "remark": "", "complete_time": 1638945904, "create_time": "1638753880", "update_time": "1638945904", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 11, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "Q/LSNQ5ifE4=", "status": 2, "goods_id": 2, "cancel_remark": "请问请问", "remark": "", "complete_time": 1638945970, "create_time": "1638753877", "update_time": "1638945970", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 10, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "ta4pqZiK+Us=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950372, "create_time": "1638753875", "update_time": "1638950372", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 9, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "Mqoj3ep8bhw=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950372, "create_time": "1638753872", "update_time": "1638950372", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 8, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "sZCbBbLnP8w=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950410, "create_time": "1638753869", "update_time": "1638950410", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 7, "site_id": 17, "employee_id": 190, "goods_name": "dddffff", "num": 1, "price": 1, "total_price": 1, "sn": "INQTFWQ8y24=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950410, "create_time": "1638753866", "update_time": "1638950410", "delete_time": null, "goods_image": "ddddd", "goods_desc": "cccccccc", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 6, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "z3/Wklt2268=", "status": 2, "goods_id": 2, "cancel_remark": "不想要", "remark": "", "complete_time": 1638514879, "create_time": "1638514822", "update_time": "1638514879", "delete_time": null, "goods_image": "https://new.gdy.g107.com/static/images/login-logo_20200603.png", "goods_desc": "宝马玩具车222", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 5, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "Fxq1K/GC+pY=", "status": 1, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 1638950410, "create_time": "1638514772", "update_time": "1638950410", "delete_time": null, "goods_image": "https://new.gdy.g107.com/static/images/login-logo_20200603.png", "goods_desc": "宝马玩具车222", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 4, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "No0/drUMdlQ=", "status": 0, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 0, "create_time": "1638514623", "update_time": "1638514623", "delete_time": null, "goods_image": "https://new.gdy.g107.com/static/images/login-logo_20200603.png", "goods_desc": "宝马玩具车222", "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }, { "id": 3, "site_id": 17, "employee_id": 190, "goods_name": "测试商品", "num": 1, "price": 2, "total_price": 2, "sn": "aZ6VskccUEk=", "status": 0, "goods_id": 2, "cancel_remark": "", "remark": "", "complete_time": 0, "create_time": "1638514513", "update_time": "1638514513", "delete_time": null, "goods_image": null, "goods_desc": null, "employee": { "id": 190, "name": "李杰", "img_url": "", "employee_detail": { "id": 190, "dept_list": [] } } }]
- data.map(item => {
- item.date = this.timestampToTime(item.create_time)
- })
- var list = that.data.list;
- if (is) {
- if (data.length < 20) {
- this.setData({
- list: list.concat(data),
- isData: true
- })
- } else {
- this.setData({
- list: list.concat(data)
- })
- }
- } else {
- this.setData({
- list: data,
- isData: false
- })
- }
- })
- },
- timestampToTime(timestamp) {
- var date = new Date(timestamp * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
- var Y = date.getFullYear() + '-';
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
- var D = date.getDate() + ' ';
- var h = date.getHours() + ':';
- var m = date.getMinutes() + ':';
- var s = date.getSeconds();
- return Y + M + D + h + m + s;
- },
- });
|