index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <view class="container">
  3. <navBar title="接口测试" :back="true" color="white" background="green" />
  4. <button @click="wxAuthLogin">微信授权登陆</button>
  5. <button @click="getUserInfo">获取用户信息</button>
  6. <button @click="updatetUserInfo">更新用户信息</button>
  7. <button @click="updatetUserInfo">更新用户信息</button>
  8. <button @click="getIndexConfig">获取首页配置</button>
  9. <button @click="postOrder">提交订单</button>
  10. <button @click="getOrderDetail">获取订单详细</button>
  11. <button @click="getMallCat">获取商城分类数据</button>
  12. <button @click="getMall">获取商城数据</button>
  13. <button @click="getSerDoc">获取服务文档数据</button>
  14. <button @click="getPricePercent">获取各个身份的价格百分比</button>
  15. <button @click="getSerBack">获取我的售后保障</button>
  16. <button @click="getSerStep">获取我的服务流程</button>
  17. <button @click="getSerBackGoods">获取我的售后商品</button>
  18. <button @click="getSerBackCon">获取我的售后联系</button>
  19. <button @click="postInvite">提交邀请</button>
  20. <button @click="getMyInvite">获取我的邀请</button>
  21. <button @click="addInvite">添加邀请</button>
  22. <button @click="addColl">添加收藏</button>
  23. <button @click="cancelColl">取消收藏</button>
  24. <button @click="getActGoods">获取活动商品</button>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. wxAuthLoginReq,
  30. getUserInfoReq,
  31. updateUserInfoReq,
  32. getIndexConfigReq,
  33. postOrderReq,
  34. getOrderDetailReq,
  35. getMallCatReq,
  36. getMallReq,
  37. getSerDocReq,
  38. getPricePercentReq,
  39. getSerBackReq,
  40. getSerStepReq,
  41. getSerBackGoodsReq,
  42. getSerBackConReq,
  43. postInviteReq,
  44. getMyInviteReq,
  45. addInviteReq,
  46. addCollReq,
  47. cancelCollReq,
  48. getActGoodsReq
  49. } from '@/api/test/index.js'
  50. export default {
  51. // components: {
  52. // navBar
  53. // },
  54. data() {
  55. return {
  56. }
  57. },
  58. methods: {
  59. async wxAuthLogin() {
  60. let res = await wxAuthLoginReq({
  61. code: '0b3nl20w3x5lh13zH53w3HRKX02nl20H'
  62. })
  63. if (res.code == 0) {
  64. console.log('微信授权登陆返回值:', res);
  65. uni.setStorageSync('token', res.data.token)
  66. } else {
  67. uni.showToast({
  68. title: res.message,
  69. icon: 'none'
  70. })
  71. }
  72. },
  73. async getUserInfo() {
  74. let res = await getUserInfoReq()
  75. if (res.code == 0) {
  76. console.log('获取用户信息返回值:', res);
  77. } else {
  78. uni.showToast({
  79. title: res.message,
  80. icon: 'none'
  81. })
  82. }
  83. },
  84. async updatetUserInfo() {
  85. let res = await updateUserInfoReq({
  86. nickname: '测试昵称',
  87. head: 'https://himg.bdimg.com/sys/portraitn/item/public.1.7bbfbe74.qTDof1r_zukwKzMF2A-cRQ',
  88. phone: '15609038521',
  89. sex: 1,
  90. name: '李万涛',
  91. birthday: '1999-01-03'
  92. })
  93. if (res.code == 0) {
  94. console.log('更新用户信息返回值:', res);
  95. } else {
  96. uni.showToast({
  97. title: res.message,
  98. icon: 'none'
  99. })
  100. }
  101. },
  102. async getIndexConfig() {
  103. let res = await getIndexConfigReq({
  104. type: 2
  105. })
  106. if (res.code == 0) {
  107. console.log('获取首页配置返回值: ', res);
  108. } else {
  109. uni.showToast({
  110. title: res.message,
  111. icon: 'none'
  112. })
  113. }
  114. },
  115. async postOrder() {
  116. let res = await postOrderReq({
  117. address: '成都市金牛区长平街70号',
  118. phone: '15609038521',
  119. name: '李万涛',
  120. remark: '备注内容',
  121. config_id: '1,3,5',
  122. lamp_id: '2,4,6'
  123. })
  124. if (res.code == 0) {
  125. console.log('提交订单返回值: ', res);
  126. } else {
  127. uni.showToast({
  128. title: res.message,
  129. icon: 'none'
  130. })
  131. }
  132. },
  133. async getOrderDetail() {
  134. let res = await getOrderDetailReq({
  135. orderId: '3bfc962f6f049082267020faf903d777',
  136. })
  137. if (res.code == 0) {
  138. console.log('获取订单详细返回值: ', res);
  139. } else {
  140. uni.showToast({
  141. title: res.message,
  142. icon: 'none'
  143. })
  144. }
  145. },
  146. async getMallCat() {
  147. let res = await getMallCatReq()
  148. if (res.code == 0) {
  149. console.log('获取商城分类数据返回值: ', res);
  150. } else {
  151. uni.showToast({
  152. title: res.message,
  153. icon: 'none'
  154. })
  155. }
  156. },
  157. async getMall() {
  158. let res = await getMallReq({
  159. page: 1,
  160. type: 1,
  161. brand: 0,
  162. search: '筒'
  163. })
  164. if (res.code == 0) {
  165. console.log('获取商城数据返回值: ', res);
  166. } else {
  167. uni.showToast({
  168. title: res.message,
  169. icon: 'none'
  170. })
  171. }
  172. },
  173. async getSerDoc() {
  174. let res = await getSerDocReq()
  175. if (res.code == 0) {
  176. console.log('获取服务文档数据返回值: ', res);
  177. } else {
  178. uni.showToast({
  179. title: res.message,
  180. icon: 'none'
  181. })
  182. }
  183. },
  184. async getPricePercent() {
  185. let res = await getPricePercentReq()
  186. if (res.code == 0) {
  187. console.log('获取各个身份的价格百分比返回值: ', res);
  188. } else {
  189. uni.showToast({
  190. title: res.message,
  191. icon: 'none'
  192. })
  193. }
  194. },
  195. async getSerBack() {
  196. let res = await getSerBackReq()
  197. if (res.code == 0) {
  198. console.log('获取我的售后保障返回值: ', res);
  199. } else {
  200. uni.showToast({
  201. title: res.message,
  202. icon: 'none'
  203. })
  204. }
  205. },
  206. async getSerStep() {
  207. let res = await getSerStepReq()
  208. if (res.code == 0) {
  209. console.log('获取我的服务流程返回值: ', res);
  210. } else {
  211. uni.showToast({
  212. title: res.message,
  213. icon: 'none'
  214. })
  215. }
  216. },
  217. async getSerBackGoods() {
  218. let res = await getSerBackGoodsReq({
  219. page: 1
  220. })
  221. if (res.code == 0) {
  222. console.log('获取我的售后商品返回值: ', res);
  223. } else {
  224. uni.showToast({
  225. title: res.message,
  226. icon: 'none'
  227. })
  228. }
  229. },
  230. async getSerBackCon() {
  231. let res = await getSerBackConReq()
  232. if (res.code == 0) {
  233. console.log('获取我的售后联系返回值: ', res);
  234. } else {
  235. uni.showToast({
  236. title: res.message,
  237. icon: 'none'
  238. })
  239. }
  240. },
  241. async postInvite() {
  242. let res = await postInviteReq({
  243. type: 0,
  244. name: '李万涛',
  245. phone: '15609038521',
  246. status: 'G-VIP',
  247. company: '思维定制科技有限公司',
  248. remark: '我的备注project_nameproject_name',
  249. project_name: 'project_name'
  250. })
  251. if (res.code == 0) {
  252. console.log('提交邀请返回值: ', res);
  253. } else {
  254. uni.showToast({
  255. title: res.message,
  256. icon: 'none'
  257. })
  258. }
  259. },
  260. async getMyInvite() {
  261. let res = await getMyInviteReq({
  262. type: 0,
  263. state: 0,
  264. })
  265. if (res.code == 0) {
  266. console.log('获取我的邀请返回值: ', res);
  267. } else {
  268. uni.showToast({
  269. title: res.message,
  270. icon: 'none'
  271. })
  272. }
  273. },
  274. async addInvite() {
  275. let res = await addInviteReq({
  276. inviteId: 'b3f48188b03b54aeb32256c825044e35',
  277. })
  278. if (res.code == 0) {
  279. console.log('添加邀请返回值: ', res);
  280. } else {
  281. uni.showToast({
  282. title: res.message,
  283. icon: 'none'
  284. })
  285. }
  286. },
  287. async addColl() {
  288. let res = await addCollReq({
  289. id: 2,
  290. })
  291. if (res.code == 0) {
  292. console.log('添加收藏返回值: ', res);
  293. } else {
  294. uni.showToast({
  295. title: res.message,
  296. icon: 'none'
  297. })
  298. }
  299. },
  300. async cancelColl() {
  301. let res = await cancelCollReq({
  302. id: 1,
  303. })
  304. if (res.code == 0) {
  305. console.log('取消收藏返回值: ', res);
  306. } else {
  307. uni.showToast({
  308. title: res.message,
  309. icon: 'none'
  310. })
  311. }
  312. },
  313. async getActGoods() {
  314. let res = await getActGoodsReq()
  315. if (res.code == 0) {
  316. console.log('获取活动商品返回值: ', res);
  317. } else {
  318. uni.showToast({
  319. title: res.message,
  320. icon: 'none'
  321. })
  322. }
  323. }
  324. }
  325. }
  326. </script>
  327. <style lang="scss" scoped>
  328. @import "./index.scss";
  329. </style>