diff --git a/app.json b/app.json index fe4280a..bbf14a6 100644 --- a/app.json +++ b/app.json @@ -1,66 +1,68 @@ { - "pages": [ - "pages/mainPage/mainPage", - "pages/login/login", - "pages/index/index", - "pages/mine/mineIndex/mine", - "pages/copyright/createProjectInfo/createProjectInfo", - "pages/copyright/createBuy/createBuy", - "pages/copyright/payment/payment", - "pages/mine/mineAccount/mineCoupons/mineCoupons", - "pages/copyright/publicPay/publicPay", - "pages/copyright/common/payState", - "pages/readTxt/readTxt", - "pages/mine/mineAccount/mineInfo/mineInfo", - "pages/mine/mineAccount/mineOrder/mineOrder", - "pages/mine/mineAccount/mineContact/mineContact", - "pages/treaty/rule/rule", - "pages/mine/mineAccount/minePayRecord/minePayRecord", - "pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage", - "pages/mine/mineAccount/invoiceInfo/invoiceInfo", - "pages/mine/mineAccount/makeInvoice/makeInvoice", - "pages/mine/mineAccount/invoiceOrder/invoiceOrder", - "pages/mine/mineAccount/invoiceRecordDetail/invoiceRecordDetail", - "pages/mine/mineAccount/mineMsgNotice/mineMsgNotice", - "pages/copyright/refund/refund", - "pages/copyright/repair/repair", - "pages/copyright/applyRepair/applyRepair", - "pages/copyright/applyRefund/applyRefund", - "pages/shop/market" - ], - "window": { - "navigationBarTextStyle": "black", - "navigationBarTitleText": "AI喵著", - "navigationBarBackgroundColor": "#ffffff" - }, - "tabBar": { - "custom": true, - "color": "#515151", - "selectedColor": "#FE9944", - "list": [{ - "pagePath": "pages/index/index", - "text": "首页", - "iconPath": "/static/images/ic_home_normal.png", - "selectedIconPath": "/static/images/ic_home_select.png" - }, - { - "pagePath": "pages/shop/market", - "text": "软著市场", - "iconPath": "/static/images/ic_home_normal.png", - "selectedIconPath": "/static/images/ic_home_select.png" - }, - { - "pagePath": "pages/mine/mineIndex/mine", - "text": "我的", - "iconPath": "/static/images/ic_mine_normal.png", - "selectedIconPath": "/static/images/ic_mine_select.png" - } - ] - }, - "style": "v2", - "componentFramework": "glass-easel", - "sitemapLocation": "sitemap.json", - "useExtendedLib": { - "weui": true - } + "pages": [ + "pages/mainPage/mainPage", + "pages/login/login", + "pages/index/index", + "pages/mine/mineIndex/mine", + "pages/copyright/createProjectInfo/createProjectInfo", + "pages/copyright/createBuy/createBuy", + "pages/copyright/payment/payment", + "pages/mine/mineAccount/mineCoupons/mineCoupons", + "pages/copyright/publicPay/publicPay", + "pages/copyright/common/payState", + "pages/readTxt/readTxt", + "pages/mine/mineAccount/mineInfo/mineInfo", + "pages/mine/mineAccount/mineOrder/mineOrder", + "pages/mine/mineAccount/mineContact/mineContact", + "pages/treaty/rule/rule", + "pages/mine/mineAccount/minePayRecord/minePayRecord", + "pages/mine/mineAccount/mineInvoiceManage/mineInvoiceManage", + "pages/mine/mineAccount/invoiceInfo/invoiceInfo", + "pages/mine/mineAccount/makeInvoice/makeInvoice", + "pages/mine/mineAccount/invoiceOrder/invoiceOrder", + "pages/mine/mineAccount/invoiceRecordDetail/invoiceRecordDetail", + "pages/mine/mineAccount/mineMsgNotice/mineMsgNotice", + "pages/copyright/refund/refund", + "pages/copyright/repair/repair", + "pages/copyright/applyRepair/applyRepair", + "pages/copyright/applyRefund/applyRefund", + "pages/shop/market/market", + "pages/shop/publishCopyright/publishCopyright" + ], + "window": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "AI喵著", + "navigationBarBackgroundColor": "#ffffff" + }, + "tabBar": { + "custom": true, + "color": "#515151", + "selectedColor": "#FE9944", + "list": [ + { + "pagePath": "pages/index/index", + "text": "首页", + "iconPath": "/static/images/ic_home_normal.png", + "selectedIconPath": "/static/images/ic_home_select.png" + }, + { + "pagePath": "pages/shop/market/market", + "text": "软著市场", + "iconPath": "/static/images/ic_home_normal.png", + "selectedIconPath": "/static/images/ic_home_select.png" + }, + { + "pagePath": "pages/mine/mineIndex/mine", + "text": "我的", + "iconPath": "/static/images/ic_mine_normal.png", + "selectedIconPath": "/static/images/ic_mine_select.png" + } + ] + }, + "style": "v2", + "componentFramework": "glass-easel", + "sitemapLocation": "sitemap.json", + "useExtendedLib": { + "weui": true + } } \ No newline at end of file diff --git a/app.wxss b/app.wxss index e669a9e..1c6534d 100644 --- a/app.wxss +++ b/app.wxss @@ -161,6 +161,12 @@ swiper-item { .mb-40 { margin-bottom: 40rpx; } +.mb-60{ + margin-bottom: 60rpx; +} +.mb-80{ + margin-bottom: 80rpx; +} .mg { margin: 10rpx; @@ -319,4 +325,9 @@ swiper-item { border-radius: 50%; background-color: var(--divider-color); margin: 0 20rpx; +} + +.weui-half-screen-dialog__ft { + height: 0; + padding: 0rpx 0rpx 50rpx; } \ No newline at end of file diff --git a/net/api/shop.js b/net/api/shop.js index 3c15d60..3d1e282 100644 --- a/net/api/shop.js +++ b/net/api/shop.js @@ -11,46 +11,93 @@ const apiPath = { updateGoods: "/api/goods/update/{goodsId}", //修改商品 PUT doCheck: "/api/goods/sub-check/{goodsId}", //提交审核 PUT onGoods: "/api/goods/publish/{goodsId}", //上架商品 PUT - offGoods: "/api/goods/no-publish/{goodsId}", //下架商品 PUT + offGoods: "/api/goods/no-publish/{goodsId}", //下架商品 + // 0b00884a-f7a2-425f-93e5-599fbaad4bde 软著分类 + // ce3ded65-68ed-4f42-89da-de1b813b8f7e 证件类型 + goodsDics: "/api/data/listbyparentid/{dId}", //商品数据字典 + areaList: "/api/area/listbyparentid/{pId}", //省市区树结构 } class Shop { - //获取上架的软著列表 + // 通用路径参数替换方法 + static #replacePathParams(path, params) { + return Object.entries(params).reduce( + (acc, [key, value]) => acc.replace(`{${key}}`, value), + path + ) + } + + // 通用请求方法 + static requestHandler(endpoint, method, data = null, pathParams = {}) { + const path = Object.keys(pathParams).length ? + this.#replacePathParams(endpoint, pathParams) : + endpoint + + return request(path, method, data, proName) + } + + // 获取上架的软著列表 static doGetIndexList(data) { - return request(apiPath.indexList, "GET", data, proName) + return this.requestHandler(apiPath.indexList, "GET", data) } - //新增软件商品 + + // 软著类型 + static doGetGoodsDic(id) { + return this.requestHandler(apiPath.goodsDics, "GET", null, { + dId: id + }) + } + + // 新增软件商品 static doSaveGoods(data) { - return request(apiPath.saveGoods, "POST", data, proName) + return this.requestHandler(apiPath.saveGoods, "POST", data) } - //商品详情 + + // 商品详情 static doGetGoodsDetail(id) { - const path = apiPath.goodsDetail.replace('{goodsId}', id) - return request(path, "GET", null, proName) + return this.requestHandler(apiPath.goodsDetail, "GET", null, { + goodsId: id + }) } - //删除商品 + + // 删除商品 static doDelGoods(id) { - const path = apiPath.delGoods.replace('{goodsId}', id) - return request(path, "DELETE", null, proName) + return this.requestHandler(apiPath.delGoods, "DELETE", null, { + ids: id + }) } - //更新商品 + + // 更新商品 static doUpdateGoods(id, data) { - const path = apiPath.updateGoods.replace('{goodsId}', id) - return request(path, "PUT", data, proName) + return this.requestHandler(apiPath.updateGoods, "PUT", data, { + goodsId: id + }) } - //提交审核 + + // 提交审核 static doSubCheck(id) { - const path = apiPath.doCheck.replace('{goodsId}', id) - return request(path, "PUT", null, proName) + return this.requestHandler(apiPath.doCheck, "PUT", null, { + goodsId: id + }) } - //上架商品 + + // 上架商品 static doOnGoods(id) { - const path = apiPath.onGoods.replace('{goodsId}', id) - return request(path, "PUT", null, proName) + return this.requestHandler(apiPath.onGoods, "PUT", null, { + goodsId: id + }) } - //下架商品 + + // 下架商品 static doOffGoods(id) { - const path = apiPath.offGoods.replace('{goodsId}', id) - return request(path, "PUT", null, proName) + return this.requestHandler(apiPath.offGoods, "PUT", null, { + goodsId: id + }) + } + //获取地区 + static doGetAreaList(id) { + return this.requestHandler(apiPath.areaList, "GET", null, { + pId: id + }) } } diff --git a/net/mainUrl.js b/net/mainUrl.js index 82a6afd..468814d 100644 --- a/net/mainUrl.js +++ b/net/mainUrl.js @@ -1,12 +1,16 @@ // 定义api服务地址 -const operatorUrl = 'https://www.aimzhu.com/operator' -const operatorPlug = 'https://www.aimzhu.com/operator-plugin' -const copyrightUrl = 'https://www.aimzhu.com/copyright' -const aiShopUrl = 'https://www.aimzhu.com/aishop' +const appUrl = 'https://www.aimzhu.com' +const prewBaseUrl = '' +const operatorUrl = appUrl + '/operator' +const operatorPlug = appUrl + '/operator-plugin' +const copyrightUrl = appUrl + '/copyright' +const aiShopUrl = appUrl + '/aishop' const uploadImgUrl = copyrightUrl + '/api/file/v2/upload-image' const previewUrl = copyrightUrl + '/route/file/v2/download/true/' -const imgAssets = 'https://www.aimzhu.com/miniapp-assets' -const appUrl = 'https://www.aimzhu.com' +const imgAssets = appUrl + '/miniapp-assets' +const sImgPrefix = aiShopUrl + '/route/file/download/true/' +const upShopImgUrl = aiShopUrl + '/api/file/v2/upload-image' + export { operatorUrl, @@ -16,5 +20,7 @@ export { copyrightUrl, aiShopUrl, imgAssets, - appUrl + appUrl, + sImgPrefix, + upShopImgUrl } \ No newline at end of file diff --git a/pages/mine/mineAccount/mineInvoice/mineInvoice.js b/pages/mine/mineAccount/mineInvoice/mineInvoice.js deleted file mode 100644 index 06b7939..0000000 --- a/pages/mine/mineAccount/mineInvoice/mineInvoice.js +++ /dev/null @@ -1,66 +0,0 @@ -// pages/mine/mineAccount/mineInvoice/mineInvoice.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady() { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide() { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload() { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh() { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom() { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage() { - - } -}) \ No newline at end of file diff --git a/pages/mine/mineAccount/mineInvoice/mineInvoice.wxml b/pages/mine/mineAccount/mineInvoice/mineInvoice.wxml deleted file mode 100644 index eb7bcb1..0000000 --- a/pages/mine/mineAccount/mineInvoice/mineInvoice.wxml +++ /dev/null @@ -1,2 +0,0 @@ - -pages/mine/mineAccount/mineInvoice/mineInvoice.wxml \ No newline at end of file diff --git a/pages/shop/market.js b/pages/shop/market.js deleted file mode 100644 index 8607d86..0000000 --- a/pages/shop/market.js +++ /dev/null @@ -1,35 +0,0 @@ -// pages/shop/market.js -const data= require('../../utils/data') -Page({ - - /** - * 页面的初始数据 - */ - data: { - tabList:data.tabList - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - - }, - - - /** - * 生命周期函数--监听页面显示 - */ - onShow() { - console.log('页面显示') - const pages = getCurrentPages(); - const currentPage = pages[pages.length - 1]; - const tabList = this.data.tabList; - tabList.forEach(item => { - item.selected = item.pagePath === currentPage.route; - }); - this.setData({ - tabList - }); - }, -}) \ No newline at end of file diff --git a/pages/shop/market.json b/pages/shop/market.json deleted file mode 100644 index d091179..0000000 --- a/pages/shop/market.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "usingComponents": { - "custom-tabbar": "/components/tabbar/custom-tabbar" - } -} \ No newline at end of file diff --git a/pages/shop/market.wxml b/pages/shop/market.wxml deleted file mode 100644 index f094b8c..0000000 --- a/pages/shop/market.wxml +++ /dev/null @@ -1,4 +0,0 @@ - - 市场 - - \ No newline at end of file diff --git a/pages/shop/market.wxss b/pages/shop/market.wxss deleted file mode 100644 index 34ef34f..0000000 --- a/pages/shop/market.wxss +++ /dev/null @@ -1 +0,0 @@ -/* pages/shop/market.wxss */ \ No newline at end of file diff --git a/pages/shop/market/market.js b/pages/shop/market/market.js new file mode 100644 index 0000000..6203545 --- /dev/null +++ b/pages/shop/market/market.js @@ -0,0 +1,243 @@ +// pages/shop/market.js +import Shop from '../../../net/api/shop' +import { + sImgPrefix, +} from '../../../net/mainUrl' +const data = require('../../../utils/data') +const app = getApp() +Page({ + + /** + * 页面的初始数据 + */ + data: { + tabList: data.tabList, + pageData: { + page: 1, + rows: 12, + keywords: '', + priceRangeStart: '', + priceRangeEnd: '', + priceOrder: '', + goodsGetTime: '', + goodsDevelop: '', + goodsType: '', //软著类型 + goodsFlag: '', + }, + keywords: '', + priceStart: '', + priceEnd: '', + isLoadMore: false, + hasMore: true, + listLoading: 'loading', + listRefreshTrig: false, + goodsList: [], + imgPrefix: sImgPrefix, + localAssets: app.globalData.localAssets, + imgAssets: app.globalData.imgAssetsUrl, + typeList: [], + selType: '', + ownerList: [{ + dataName: '从高到低', + dataId: 'DESC' + }, { + dataName: '从低到高', + dataId: 'ASC' + }], + selOwner: '', + isSticky: false, + msgType: 'info', + msgHint: '', + msgShow: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + wx.setNavigationBarTitle({ + title: '商城', + }) + wx.setNavigationBarColor({ + frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000 + backgroundColor: '#FFFFFF', // 传递的颜色值,仅支持十六进制颜色 + animation: { // 可选项 + duration: 500, + timingFunc: 'easeIn' + } + }) + this.doGetDic() + this.doRefreshList() + }, + + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + console.log('页面显示') + const pages = getCurrentPages(); + const currentPage = pages[pages.length - 1]; + const tabList = this.data.tabList; + tabList.forEach(item => { + item.selected = item.pagePath === currentPage.route; + }); + this.setData({ + tabList + }); + }, + onPageScroll(e) { + this.setData({ + isSticky: e.scrollTop > 190 + }) + }, + onPullDownRefresh() { + this.doRefreshList() + }, + onReachBottom(e) { + console.log('触底了') + this.doLoadMore() + }, + inputKeywords(e) { + this.setData({ + keywords: e.detail.value + }) + }, + doSearch() { + this.doRefreshList() + }, + bindChooseType(e) { + wx.pageScrollTo({ + scrollTop: 0 + }) + setTimeout(() => { + const item = e.currentTarget.dataset.item; + let newSelType = this.data.selType; + // 先转数组,处理空字符串情况 + const typeArr = newSelType ? newSelType.split(',') : []; + + if (typeArr.includes(item.dataId)) { + // 删除 + const index = typeArr.indexOf(item.dataId); + typeArr.splice(index, 1); + } else { + // 添加 + typeArr.push(item.dataId); + } + + // 转回字符串,自动处理空数组(转成空字符串) + newSelType = typeArr.join(','); + + this.setData({ + selType: newSelType + }); + console.log('选择分类:', this.data.selType); + this.doRefreshList(); + }, 500); + }, + bindChooseOwner(e) { + const item = e.currentTarget.dataset.item + this.setData({ + selOwner: this.data.selOwner == item.dataId ? '' : item.dataId + }) + this.doRefreshList() + }, + doGetDic() { + wx.showLoading({ + title: '加载中...', + }) + const that = this + Shop.doGetGoodsDic('0b00884a-f7a2-425f-93e5-599fbaad4bde') + .then(res => { + wx.hideLoading() + that.setData({ + typeList: res + }) + }) + .catch(err => { + wx.hideLoading() + }) + }, + //刷新 + doRefreshList() { + const _self = this + console.log('页面刷新:分类', _self.data.selType) + this.setData({ + goodsList: [], + isLoadMore: false, + hasMore: true, + listRefreshTrig: true, + 'pageData.page': 1, + 'pageData.keywords': _self.data.keywords, + 'pageData.priceOrder': _self.data.selOwner, + 'pageData.priceRangeStart': _self.data.priceStart, + 'pageData.priceRangeEnd': _self.data.priceEnd, + 'pageData.goodsType': _self.data.selType, + }) + console.log('刷新页面', _self.data.pageData.page) + _self.getIndexList(true) + }, + //加载更多 + doLoadMore() { + console.log('加载更多:', this.data.isLoadMore, this.data.hasMore) + const _self = this + if (_self.data.isLoadMore || !_self.data.hasMore) { + return + } + //判断是否有更多 + _self.setData({ + isLoadMore: true, + 'pageData.page': ++_self.data.pageData.page + }) + _self.getIndexList(false) + }, + //获取列表 + getIndexList(isRefresh) { + const _self = this + _self.setData({ + listLoading: isRefresh ? 'loading' : '' + }) + Shop.doGetIndexList(_self.data.pageData) + .then(res => { + console.log(res) + wx.stopPullDownRefresh() + var status = 'success' + status = res.rows && res.rows.length > 0 ? 'success' : 'empty' + const list = _self.addPrefixToPreviewImgs(res.rows) + _self.setData({ + listLoading: isRefresh ? status : '', + goodsList: _self.data.goodsList.concat(list), + listRefreshTrig: false, + isLoadMore: false, + }) + _self.setData({ + hasMore: _self.data.goodsList.length < res.total + }) + }) + .catch(err => { + wx.stopPullDownRefresh() + console.log(err) + _self.setData({ + listLoading: 'error', + listRefreshTrig: false, + isLoadMore: false, + hasMore: true + }) + }) + }, + //为数据中图片添加前缀 + addPrefixToPreviewImgs(data) { + const prefix = this.data.imgPrefix; + return data.map(item => { + if (item.goodsPhoto && item.goodsPhoto != '') { + item.preImg = prefix + item.goodsPhoto + } + return item; + }); + }, + doPublish() { + wx.navigateTo({ + url: '/pages/shop/publishCopyright/publishCopyright', + }) + } +}) \ No newline at end of file diff --git a/pages/shop/market/market.json b/pages/shop/market/market.json new file mode 100644 index 0000000..02edbc4 --- /dev/null +++ b/pages/shop/market/market.json @@ -0,0 +1,9 @@ +{ + "usingComponents": { + "custom-tabbar": "/components/tabbar/custom-tabbar", + "container-loading": "/components/container-loading/container-loading", + "mp-loading": "weui-miniprogram/loading/loading", + "mp-toptips": "weui-miniprogram/toptips/toptips" + }, + "enablePullDownRefresh": true +} \ No newline at end of file diff --git a/pages/shop/market/market.wxml b/pages/shop/market/market.wxml new file mode 100644 index 0000000..7e66908 --- /dev/null +++ b/pages/shop/market/market.wxml @@ -0,0 +1,102 @@ + + + + + + 搜索 + + + + + + + AI喵著 为您提供一站式服务 + + + + 选的省心 + + + + 买的放心 + + + + 用的安心 + + + + + + 已购买 + + + + 我要卖 + + + + 已销售 + + + + + + + + + + 软著分类 + + + + + {{item.dataName}} + + + + + + + 所属者类型 + + + + + {{item.dataName}} + + + + + + + + + + + + + + + + + + {{item.goodsName}} + + + {{item.goodsLastTime}} + + 特价 + + + + + + + + + + + + + \ No newline at end of file diff --git a/pages/shop/market/market.wxss b/pages/shop/market/market.wxss new file mode 100644 index 0000000..d4e5e9f --- /dev/null +++ b/pages/shop/market/market.wxss @@ -0,0 +1,298 @@ +.search-container-fixed { + position: fixed; + top: 0; + left: 0; + display: flex; + flex-direction: column; + box-sizing: border-box; + width: 100%; + z-index: 99; +} + +.search-box { + background-color: var(--bg-gray-color); + display: flex; + flex-direction: row; + align-items: center; + margin: 0rpx 30rpx 0rpx 30rpx; + padding: 15rpx 20rpx; + border-radius: 60rpx; + font-size: 28rpx; +} + +.search-input { + flex: 1; +} + +.divider-20 { + background-color: var(--bg-gray-input-color); + min-height: 20rpx; + margin: 0rpx -30rpx; +} + +.title-box { + position: relative; + margin-top: 60rpx; + padding: 30rpx; +} + +.title-bg { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 300rpx; + background-size: cover; +} + +.title-container { + position: relative; +} + +.title-hint-box { + display: flex; + flex-direction: row; + margin-top: 20rpx; +} + +.title-hint-item { + display: flex; + flex-direction: row; + align-items: center; +} + +.title-hint-item:nth-of-type(n+2) { + margin-left: 30rpx; +} + +.title-hint-txt { + margin-left: 8rpx; + font-size: 24rpx; + color: var(--text-gray-desc-color); +} + +.hook { + width: 32rpx; + height: 32rpx; + border-radius: 50%; + background: linear-gradient(0deg, #FFB540 0%, #FF4800 100%); + position: relative; + display: flex; + align-items: center; + justify-content: center; +} + +.hook::after { + content: ""; + display: block; + width: 8rpx; + height: 15rpx; + border: solid white; + border-width: 0 2rpx 2rpx 0; + transform: rotate(45deg); + position: absolute; + top: 6rpx; +} + +.title-func-box { + display: flex; + flex-direction: row; + margin-top: 30rpx; +} + +.title-func-item { + display: flex; + flex-direction: column; + align-items: center; +} + +.title-func-item:nth-of-type(n+2) { + margin-left: 40rpx; +} + +.func-img { + width: 120rpx; + height: 120rpx; +} + +.func-txt { + font-size: 28rpx; + color: var(--text-color); + margin-top: 15rpx; +} + +.container-box { + display: flex; + flex-direction: column; +} + +.header { + transition: all 0.3s; + background-color: var(--white-color); +} + +.header.sticky { + position: fixed; + /* padding: 20rpx 30rpx; */ + background-color: var(--white-color); + box-sizing: border-box; + padding: 20rpx 30rpx 0rpx 30rpx; + top: 70rpx; + left: 0; + right: 0; + z-index: 100; + box-shadow: 0 2rpx 4rpx var(--bg-gray-input-color); +} + +.condition-box { + display: flex; + flex-direction: column; + padding: 30rpx 0rpx; +} + +.condition-item { + display: flex; + flex-direction: row; + justify-content: flex-start; + align-items: center; +} + +.condition-item-title { + white-space: nowrap; + font-size: 24rpx; +} + +.list-tabs { + display: flex; + flex-direction: row; + flex-wrap: nowrap; +} + +.tab-select { + white-space: nowrap; + line-height: 17px; + border-radius: 5rpx; + background-color: var(--btn-primary-color); + color: var(--text-primary-deep-color); + font-size: 24rpx; + text-align: center; + padding: 5rpx 15rpx; +} + +.tab-normal { + background-color: var(--bg-gray-input-color); + color: var(--text-gray-hint-color); + white-space: nowrap; + line-height: 17px; + border-radius: 5rpx; + font-size: 24rpx; + text-align: center; + padding: 5rpx 15rpx; +} + +.item-margin { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; +} + +.item-margin:nth-of-type(n+2) { + margin-left: 20rpx; +} + +.content-container { + display: flex; + flex-direction: column; + margin-bottom: 180rpx; + position: relative; +} + +.loading-box { + position: absolute; + top: 50%; + left: 50%; + z-index: 99; + transform: translate(-50%, -50%); +} + +.content-box { + display: flex; + flex-direction: row; + flex-wrap: wrap; +} + +.content-item { + width: 48%; + margin-top: 20rpx; + position: relative; +} + +.content-item:nth-of-type(even) { + margin-left: 20rpx; +} + + +.special-tag { + display: inline-block; + padding: 0rpx 20rpx; + background-color: var(--red-color); + color: #fff; + font-size: 22rpx; + border-bottom-right-radius: 30rpx; + border-top-right-radius: 30rpx; + position: absolute; + top: 0rpx; + left: 0rpx; +} + +.special-tag::before { + content: ''; + position: absolute; + left: 0rpx; + bottom: -15rpx; + border-width: 18rpx 18rpx 0 0rpx; + border-style: solid; + border-color: var(--red-color) transparent transparent transparent; +} + + +.content-item-img-box { + border-radius: 10rpx; + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + padding: 20rpx; + background-color: var(--bg-gray-input-color); +} + +.content-item-img { + width: 200rpx; + height: 260rpx; +} + +.content-item-txt { + font-size: 28rpx; + margin-top: 15rpx; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + max-width: 100%; +} + +.content-item-bottom { + display: flex; + flex-direction: row; + justify-content: space-between; +} + +.content-item-time { + font-size: 24rpx; + color: var(--text-gray-hint-color); +} + +.content-item-price { + color: red; + font-size: 28rpx; +} \ No newline at end of file diff --git a/pages/shop/publishCopyright/publishCopyright.js b/pages/shop/publishCopyright/publishCopyright.js new file mode 100644 index 0000000..c817ce5 --- /dev/null +++ b/pages/shop/publishCopyright/publishCopyright.js @@ -0,0 +1,449 @@ +// pages/shop/publishCopyright/publishCopyright.js +import Shop from '../../../net/api/shop' +import { + upShopImgUrl +} from '../../../net/mainUrl' +const { + isValidPhone +} = require('../../../utils/validator') +const Utils = require('../../../utils/util') +const Cache = require('../../../utils/storage') +Page({ + + /** + * 页面的初始数据 + */ + data: { + // 0b00884a-f7a2-425f-93e5-599fbaad4bde 软著分类 + // ce3ded65-68ed-4f42-89da-de1b813b8f7e 证件类型 + curStartDate: Utils.currentDate(), + personType: [{ + dataName: '自然人', + dataId: '1' + }, { + dataName: '法人', + dataId: '2' + }, { + dataName: '非法人组织或其他', + dataId: '3' + }], + selPersonType: null, + creType: [], + rightType: [], + areaList: [], //省 + cityList: [], //市 + rightName: '', //软著名称 + orgName: '', //著作权人姓名 + orgPhone: '', //联系电话 + cardNumber: '', //证件号码 + selRightType: [], //选中分类 + rightPrice: '', //售价 + rightStopDate: '', //停止日期 + selCreType: null, //选中证件类型 + showArea: false, + prevValue: [0, 0], // 用于存储上一次的值 + selArea: null, + selCity: null, + msgHint: '', + msgType: 'info', + msgShow: false, + files: [], + showType: false + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + wx.setNavigationBarTitle({ + title: '软著发布', + }) + wx.setNavigationBarColor({ + frontColor: '#000000', // 必写项,字体颜色仅支持#ffffff和#000000 + backgroundColor: '#F0F0F0', // 传递的颜色值,仅支持十六进制颜色 + animation: { // 可选项 + duration: 500, + timingFunc: 'easeIn' + } + }) + this.setData({ + selPersonType: this.data.personType[0], + selectFile: this.selectFile.bind(this), + uploadFile: this.uploadFile.bind(this) + }) + this.getDic() + }, + inputRightName(e) { + this.setData({ + rightName: e.detail.value + }) + }, + inputRightPrice(e) { + this.setData({ + rightPrice: e.detail.value + }) + }, + inputOrgName(e) { + this.setData({ + orgName: e.detail.value + }) + }, + inputCardNumber(e) { + this.setData({ + cardNumber: e.detail.value + }) + }, + //著作权人类别 + bindChangePersonType(e) { + this.setData({ + selPersonType: this.data.personType[e.detail.value] + }) + }, + clearPersonType() { + this.setData({ + selPersonType: null + }) + }, + //证件类型 + bindChangeCreType(e) { + this.setData({ + selCreType: this.data.creType[e.detail.value] + }) + }, + clearCreType() { + this.setData({ + selCreType: null + }) + }, + //选择软著分类 + onShowRightType() { + this.setData({ + showType: true + }) + }, + bindChangeRightType(e) { + const selectedIds = new Set(e.detail.value); + const rightTypeMap = new Map(); + this.data.rightType.forEach(item => { + rightTypeMap.set(item.dataId, item); + }); + const selRightType = [...selectedIds].map(id => { + const item = rightTypeMap.get(id); + if (item) { + item.checked = true; + } + return item; + }).filter(Boolean); + this.setData({ + selRightType, + rightType: [...this.data.rightType] + }); + }, + clearRightType() { + this.data.rightType.forEach(item => { + item.checked = false + }) + this.setData({ + selRightType: [], + rightType: this.data.rightType + }) + }, + confirmSelRightType() { + this.setData({ + showType: false + }) + }, + //显示日期选择 + bindDateChange(e) { + this.setData({ + rightStopDate: e.detail.value + }) + }, + clearTime() { + this.setData({ + rightStopDate: '' + }) + }, + deleteImage(e) { + var index = e.detail.index; + this.data.files.splice(index, 1); + }, + selectFile(files) { + console.log('files', files) + }, + uploadFile(files) { + console.log(files) + const tempFilePaths = files.tempFilePaths; + const token = Cache.get('token') + const header = {} + if (token) { + header.Auth = `Bearer ${token}`; + } + var that = this + for (let i = 0; i < tempFilePaths.length; i++) { + wx.uploadFile({ + url: upShopImgUrl, + header: header, + filePath: tempFilePaths[i], + name: 'image', + success(res) { + console.log(res) + let result = JSON.parse(res.data) + that.data.files.push(result.data) + }, + fail(err) { + console.log(err); + } + }) + } + + // 文件上传的函数,返回一个promise + return new Promise((resolve, reject) => { + var result = {}; + result['urls'] = tempFilePaths; + resolve(result); + }) + }, + //显示地区选择 + onShowArea() { + this.setData({ + showArea: true + }) + }, + clearArea() { + this.setData({ + selArea: null, + selCity: null + }) + }, + confirmSelArea() { + this.setData({ + showArea: false + }) + }, + inputOrgPhone(e) { + this.setData({ + orgPhone: e.detail.value + }) + }, + getDic() { + const _self = this + const cre = Shop.doGetGoodsDic('0b00884a-f7a2-425f-93e5-599fbaad4bde') //软著分类 + const right = Shop.doGetGoodsDic('ce3ded65-68ed-4f42-89da-de1b813b8f7e') //证件类型 + const area = Shop.doGetAreaList('0') + const list = [cre, right, area] + Promise.all(list) + .then(res => { + if (res) { + _self.setData({ + rightType: res[0], + creType: res[1], + areaList: res[2] + }) + _self.data.rightType.forEach(item => { + item.checked = false + }) + //默认加载第一个area + _self.setData({ + selCreType: _self.data.creType[0], + selArea: _self.data.areaList[0], + rightType: _self.data.rightType + }) + _self.doGetArea(_self.data.selArea.areaId) + } + }) + .catch(err => { + _self.setData({ + msgShow: true, + msgHint: '数据加载错误,请稍后重试', + msgType: 'error' + }) + setTimeout(() => { + wx.navigateBack() + }, 1500); + }) + + }, + //获取区域 + doGetArea(pId) { + wx.showLoading({ + title: '加载中...', + }) + const _self = this + Shop.doGetAreaList(pId) + .then(res => { + wx.hideLoading() + console.log(res) + if (res) { + _self.setData({ + cityList: res, + selCity: res[0] + }) + } + + }) + .catch(err => { + wx.hideLoading() + _self.setData({ + msgShow: true, + msgHint: '数据加载错误,请稍后重试', + msgType: 'error' + }) + }) + }, + //选中省市 + areaChange(e) { + const _self = this + const currentValue = e.detail.value; + const prevValue = _self.data.prevValue; + _self.setData({ + prevValue: currentValue + }); + for (let i = 0; i < currentValue.length; i++) { + if (currentValue[i] !== prevValue[i]) { + if (i == 0) { + //获取city + const area = _self.data.areaList[currentValue[0]] + _self.setData({ + selArea: area + }) + _self.doGetArea(area.areaId) + } else { + const city = _self.data.cityList[currentValue[1]] + _self.setData({ + selCity: city + }) + } + } + } + }, + //保存商品 + doSave() { + const isLegal = this.checkParams() + if (isLegal) { + const _self = this + const data = _self.buildParams() + wx.showLoading({ + title: '保存中...', + }) + Shop.doSaveGoods(data) + .then(res => { + wx.hideLoading() + _self.setData({ + msgType: 'success', + msgHint: '保存成功', + msgShow: true + }) + setTimeout(() => { + wx.navigateBack() + }, 1500); + }) + .catch(err => { + wx.hideLoading() + _self.setData({ + msgType: 'error', + msgHint: err.msg ? err.msg : '网络错误,请稍后重试', + msgShow: true + }) + }) + } + }, + //校验参数 + checkParams() { + const rules = [{ + field: 'rightName', + message: '请输入软著名称', + validator: v => v.trim() !== '' + }, + { + field: 'selRightType', + message: '请选择软著分类', + validator: v => v !== null + }, + { + field: 'rightPrice', + message: '请输入软著售价', + validator: v => v.trim() !== '' + }, + { + field: 'rightStopDate', + message: '请选择截止售卖日期', + validator: v => v.trim() !== '' + }, + { + field: 'files', + message: '请上传软著图片', + validator: v => v && v.length > 0 + }, + { + field: 'selPersonType', + message: '请选择著作权人类别', + validator: v => v !== null + }, + { + field: 'orgName', + message: '请输入姓名或机构名称', + validator: v => v.trim() !== '' + }, + { + field: ['selArea', 'selCity'], + message: '请选择所在省市', + validator: (_, data) => data.selArea !== null && data.selCity !== null + }, + { + field: 'orgPhone', + message: '请输入合法的联系电话', + validator: v => v.trim() !== '' && isValidPhone(v.trim()) + }, + { + field: 'selCreType', + message: '请选择证件类型', + validator: v => v !== null + }, + { + field: 'cardNumber', + message: '请输入证件号码', + validator: v => v.trim() !== '' + } + ]; + + for (const rule of rules) { + let isValid; + if (Array.isArray(rule.field)) { + // 多字段联合验证 + isValid = rule.validator(null, this.data); + } else { + // 单字段验证 + const value = this.data[rule.field]; + isValid = rule.validator(value, this.data); + } + + if (!isValid) { + this.setData({ + msgType: 'error', + msgHint: rule.message, + msgShow: true + }); + return false; + } + } + return true; + }, + buildParams() { + const data = { + goodsLastTime: this.data.rightStopDate, + goodsLeader: this.data.orgName, + goodsLeaderCity1: this.data.selArea.areaId, + goodsLeaderCity2: this.data.selCity.areaId, + goodsLeaderIdcard: this.data.cardNumber, + goodsLeaderIdcardType: this.data.selCreType.dataId, + goodsLeaderPhone: this.data.orgPhone, + goodsLeaderType: this.data.selPersonType.dataId, + goodsName: this.data.rightName, + goodsLocalPhoto: this.data.files[0].fileId, + goodsPrice: this.data.rightPrice, + goodsType: this.data.selRightType.dataId + } + return data + } +}) \ No newline at end of file diff --git a/pages/shop/publishCopyright/publishCopyright.json b/pages/shop/publishCopyright/publishCopyright.json new file mode 100644 index 0000000..762c968 --- /dev/null +++ b/pages/shop/publishCopyright/publishCopyright.json @@ -0,0 +1,7 @@ +{ + "usingComponents": { + "mp-half-screen-dialog": "weui-miniprogram/half-screen-dialog/half-screen-dialog", + "mp-toptips": "weui-miniprogram/toptips/toptips", + "mp-uploader": "weui-miniprogram/uploader/uploader" + } +} \ No newline at end of file diff --git a/pages/shop/publishCopyright/publishCopyright.wxml b/pages/shop/publishCopyright/publishCopyright.wxml new file mode 100644 index 0000000..983da40 --- /dev/null +++ b/pages/shop/publishCopyright/publishCopyright.wxml @@ -0,0 +1,157 @@ + + + 软著信息 + + + + 软著名称 + + + + + + 软著分类 + + + 请选择软著分类 + + + + {{item.dataName}} + + + + + + + + + + + + + 售卖价格 + + + + + + 截止售卖日期 + + + {{rightStopDate != ''? rightStopDate:'请选择截止售卖日期'}} + + + + + + + + + 软著图片 + + + + + + + + 著作权人信息 + + + + 类别 + + + {{selPersonType != null? selPersonType.dataName:'请选择类别'}} + + + + + + + + + 姓名或机构名称 + + + + + + 所在省市 + + {{selArea != null? selArea.areaName+'/'+selCity.areaName:'请选择所在省市'}} + + + + + + + + 联系电话 + + + + + + 证件类型 + + + {{selCreType != null? selCreType.dataName:'请选择证件类型'}} + + + + + + + + + 证件号码 + + + + + + + + 保存 + + + + + 软件分类 + + + + + + + {{item.dataName}} + + + + + + + + 确定 + + + + + 省市 + + + + {{item.areaName}} + + + {{item.areaName}} + + + + + 确定 + + + \ No newline at end of file diff --git a/pages/shop/publishCopyright/publishCopyright.wxss b/pages/shop/publishCopyright/publishCopyright.wxss new file mode 100644 index 0000000..880c8fe --- /dev/null +++ b/pages/shop/publishCopyright/publishCopyright.wxss @@ -0,0 +1,195 @@ +/* pages/shop/publishCopyright/publishCopyright.wxss */ + +.content-box { + border-radius: 20rpx; + padding: 20rpx; + background-color: var(--white-color); + margin-top: 20rpx; +} + +.info-title { + font-size: 36rpx; + font-weight: bold; + display: flex; + flex-direction: row; + align-items: center; +} + +.info-title::before { + content: ""; + width: 10rpx; + height: 36rpx; + margin-right: 8rpx; + border-left: 10rpx solid var(--primary-color); + border-radius: 4rpx; + vertical-align: middle; +} + +.section { + margin-bottom: 15rpx; +} + +.item { + display: flex; + flex-direction: column; + margin-bottom: 10rpx; + padding: 20rpx 10rpx; + font-size: 28rpx; +} + +.label { + color: var(--text-color); + font-weight: bold; +} + +.select-content { + margin-top: 15rpx; + display: flex; + height: 70rpx; + flex-direction: row; + border-radius: 5rpx; + background-color: var(--bg-gray-input-color); + padding: 0rpx 10rpx; +} + +.select-content-no-h { + margin-top: 15rpx; + display: flex; + flex-direction: row; + align-items: center; + min-height: 70rpx; + flex-direction: row; + border-radius: 5rpx; + background-color: var(--bg-gray-input-color); + padding: 0rpx 15rpx; +} + +.select-content-item { + margin-top: 15rpx; + display: flex; + flex-direction: row; + align-items: center; + height: 70rpx; + flex-direction: row; + border-radius: 5rpx; + background-color: var(--bg-gray-input-color); + padding: 0rpx 15rpx; +} + +.select-item-box { + flex: 1; + display: flex; + flex-direction: row; + flex-wrap: wrap; + padding: 5rpx; +} + +.select-item-item { + display: flex; + flex-direction: row; + align-items: center; + background-color: var(--divider-color); + padding: 5rpx 15rpx; + border-radius: 5rpx; +} + +.select-item-item:nth-of-type(n+1) { + margin: 8rpx; +} + +.desc { + flex: 1; + color: #999; + text-align: left; + padding-left: 20rpx; + display: flex; + flex-direction: row; + justify-content: space-between; + padding-right: 10px; + align-items: center; +} + +.select-time { + color: var(--text-color); + flex: 1; + font-size: 28rpx; + text-align: left; +} + +.clear-icon { + width: 20px; + height: 20px; + margin-right: 20rpx; +} + +.value { + flex: 1; + text-align: left; + font-size: 28rpx; +} + + +.value-hint { + color: var(--text-gray-hint-color); +} + +.v-select { + color: var(--text-color); +} + +.v-normal { + color: var(--text-gray-hint-color) +} + +.custom-dialog { + background-color: var(--white-color); +} + +.custom-tips { + margin-top: 80px; +} + +/* 上传图片 */ + +.weui-uploader { + margin-top: 10rpx; + width: 100%; +} + +.weui-uploader__bd { + display: flex; + flex-direction: row; + margin-bottom: 0; +} + +.weui-uploader__hd { + display: none; +} + +.weui-uploader__input-box { + width: 65px; + height: 65px; + border-radius: 5px; +} + +.weui-uploader__file { + width: 65px; + height: 65px; + border-radius: 5px; +} + +.weui-uploader__img { + border-radius: 5px; +} + +.weui-uploader__overview { + display: flex; + flex-direction: row; + justify-content: space-between; + width: 65vw; +} + +.weui-uploader__input-box { + background: white; + border: 1px solid var(--divider-color); +} \ No newline at end of file diff --git a/static/images/icon_betray.png b/static/images/icon_betray.png new file mode 100755 index 0000000..4826709 Binary files /dev/null and b/static/images/icon_betray.png differ diff --git a/static/images/icon_buy.png b/static/images/icon_buy.png new file mode 100755 index 0000000..21326a5 Binary files /dev/null and b/static/images/icon_buy.png differ diff --git a/static/images/icon_purchase.png b/static/images/icon_purchase.png new file mode 100755 index 0000000..8b8269e Binary files /dev/null and b/static/images/icon_purchase.png differ diff --git a/static/images/icon_sell.png b/static/images/icon_sell.png new file mode 100755 index 0000000..21f36f1 Binary files /dev/null and b/static/images/icon_sell.png differ diff --git a/static/style/common.wxss b/static/style/common.wxss index 4b3be95..ef06be6 100644 --- a/static/style/common.wxss +++ b/static/style/common.wxss @@ -20,6 +20,7 @@ page { --text-gray-hint-color: #9A9A9A; --text-gray-desc-color: #5c5c5c; --text-blue-color: #3270FF; + --text-primary-deep-color: #FF6700; /* 背景棕色 */ --bg-brown-color: #42210B; --bg-gray-color: #FAFAFA; diff --git a/utils/comm.wxs b/utils/comm.wxs index 4ff2dc2..d13220f 100644 --- a/utils/comm.wxs +++ b/utils/comm.wxs @@ -96,6 +96,9 @@ var coverTxt = function (price) { var moneyTxt = function (size, price) { return '' + price } +var includes = function (str, target) { + return str && str.indexOf(target) !== -1; +} var payType = function (type) { // 充值1|支出2|提现3|系统扣款4|订单收入5|付款6) var typeStr = '支出' @@ -379,5 +382,6 @@ module.exports = { repairStatusColor: repairStatusColor, repairType: repairType, repairKind: repairKind, - phoneNum: phoneNum + phoneNum: phoneNum, + includes: includes }; \ No newline at end of file diff --git a/utils/data.js b/utils/data.js index 42a7f40..ec63b30 100644 --- a/utils/data.js +++ b/utils/data.js @@ -37,8 +37,8 @@ const tabList = [{ "hasMsg": false }, { - "pagePath": "pages/shop/market", - "text": "软著市场", + "pagePath": "pages/shop/market/market", + "text": "商城", "iconPath": "/static/images/ic_home_normal.png", "selectedIconPath": "/static/images/ic_home_select.png", "selected": false, diff --git a/utils/util.js b/utils/util.js index 20788ad..936f046 100644 --- a/utils/util.js +++ b/utils/util.js @@ -91,6 +91,16 @@ const formatDate = date => { return [year, month, day].map(formatNumber).join('-') } +/** + * 获取当前日期 + */ +const currentDate = () => { + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, '0'); // 月份+1(0~11) + const day = String(now.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}`; +} const formatNumber = n => { n = n.toString() @@ -198,5 +208,6 @@ module.exports = { removeImgStyle: removeImgStyleFromRichText, dateTimePicker: dateTimePicker, pxToRpx: pxToRpx, - random32Str: random32Str + random32Str: random32Str, + currentDate: currentDate } \ No newline at end of file