collect-data.vue
- <view>
- 批量读取并录入分类
- <button type="default" @tap="haddleCfy">转录分类button>
- <button type="default" @tap="haddleGoods">转录商品button>
- view>
-
- <script>
- export default {
- data() {
- return {
-
- };
- },
- methods: {
- haddleCfy() {
- uni.request({
- url: "https://h******om/api/5e90690f0e270d04?cityId=110",
- method: "GET",
- header: {
- "access-token": "b1965ae1dfb72c63fb84a47e079f84fa",
- "version": "v1.0"
- },
- success: (res) => {
- // console.log(res);
- let {
- data
- } = res.data
- let batchObj = {
- "requests": []
- }
- data.forEach(item => {
- batchObj.requests.push({
- "method": "POST",
- "path": "/1.1/classes/classify",
- "body": item
- })
- })
- console.log(batchObj);
- // this.$post('/1.1/batch',batchObj) //批量录入分类
- }
- })
- },
- haddleGoods() {
-
- uni.request({
- url: "https://h*****om/api/0434b49d1ac28f9d?cityId=110&page=1&bid=6",
- method: "GET",
- header: {
- "access-token": "b1965ae1dfb72c63fb84a47e079f84fa",
- "version": "v1.0"
- },
- success: (res) => {
- console.log(res);
- let {
- list
- } = res.data.data
- let batchObj = {
- "requests": []
- }
- list.forEach(item => {
- batchObj.requests.push({
- "method": "POST",
- "path": "/1.1/classes/goods",
- "body": item
- })
- })
- // console.log(batchObj);
- this.$post('/1.1/batch',batchObj) //批量录入分类
- }
- })
- }
-
- }
- }
- script>
-
- <style lang="scss">
-
- style>