1234567891011121314151617181920212223242526272829303132 |
- import 'dart:convert';
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:flutter_note/config/service_url.dart';
- import 'package:flutter_note/model/goods_detail_model.dart';
- import 'package:flutter_note/service/service_method.dart';
- class GoodsDetailProvide with ChangeNotifier {
- GoodsDetailModel _detail; // 商品详情
- int _detailIndex; // 详情页的 tabIndex
- GoodsDetailModel get detail => _detail;
- int get detailIndex => _detailIndex;
- changeDetails(String id) async {
- _detail = await getGoodsDetail(id);
- notifyListeners();
- }
- changeIndex(int index) {
- _detailIndex = index;
- notifyListeners();
- }
- Future<GoodsDetailModel> getGoodsDetail(String id) async {
- var response = await request(servicePath['getGoodDetailById'],
- formData: {'goodId': id});
- return GoodsDetailModel.fromMap(json.decode(response.data));
- }
- }
|